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
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 CenterFile Exchange에서 Interactive Control and Callbacks에 대해 자세히 알아보기

제품


릴리스

R2021a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by