The color of the defined axis changes when I print the figure to PDF
2 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Sven Ole Deist
le 21 Fév 2023
Commenté : Sven Ole Deist
le 21 Fév 2023
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]);
Réponse acceptée
Anton Kogios
le 21 Fév 2023
Instead of using the print function, you can use exportgraphics:
exportgraphics(fig,[printfolder,print_name,'.png']);
exportgraphics(fig,[printfolder,print_name,'.pdf']);
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Interactive Control and Callbacks dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!