The color of the defined axis changes when I print the figure to PDF

2 ビュー (過去 30 日間)
Sven Ole Deist
Sven Ole Deist 2023 年 2 月 21 日
コメント済み: Sven Ole Deist 2023 年 2 月 21 日
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 Center および File ExchangeInteractive 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