The color of the defined axis changes when I print the figure to PDF
2 次查看(过去 30 天)
显示 更早的评论
Hi everyone,
I need some help. The following shows a simple code plotting a curve into a defined figure. I want to change the axis color (in this case to white). Actually this is working perfectly when I am running the bold part seperatly. But when I am initializing a figure and print it in the end, my png file shows a plot with black axis again.
I hope some of you have a solution for my little problem.
Ty already
Sven
%Figure initialize
clear all; clc;
close all;
fig=figure (1);
width_single = 9;
figheight=10;
fig.Units = 'centimeters';
fig.PaperOrientation='Landscape';
fig.Position = [-50 2 width_single*3 figheight*3];
fig.PaperPosition = [0 0 width_single*3 figheight*3];
fig.PaperUnits = 'centimeters';
fig.PaperSize = [fig.PaperPosition(3) fig.PaperPosition(4)];
%Random Plot
X = 1 : 20;
Y = rand(1, 20);
plot(X, Y);
set(gca,'YDir','normal','XDir','normal', 'FontSize',18, 'XColor', 'w','YColor', 'w'); % Define axis color to white
%ENTER FOLDER PATH
printfolder=['E:\...\'];
if ~exist(printfolder)
mkdir (printfolder)
end
print_name=['Test'];
print(fig,'-dpng',[printfolder,print_name]);
采纳的回答
Anton Kogios
2023-2-21
Instead of using the print function, you can use exportgraphics:
exportgraphics(fig,[printfolder,print_name,'.png']);
exportgraphics(fig,[printfolder,print_name,'.pdf']);
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Interactive Control and Callbacks 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!