Clear Filters
Clear Filters

How can i export figure with all bold axes saved?

1 view (last 30 days)
when i using following code, ploting is okay, and not all bold axes saved?
I am using R2019a
clc;clear all;close all;
% define size of picture
f=figure;
f.Units='centimeters';
ax=gca;
ax.LineWidth=1.5;
ax.FontSize = 10;
set(gca,'box','on')
set(gca, 'FontName', 'Times New Roman');
set(gcf,'Position',[5 10 7 7*0.618])
hold on
% data and plot
datax=linspace(0,2,2000000);
freq=1;
w=2*pi*freq;
datay=0.1*sin(w*datax);
plot(datax,datay,'-k',...
'LineWidth',1.2,...
'MarkerSize',10,...
'MarkerEdgeColor','b',...
'MarkerFaceColor',[0.5,0.5,0.5])
% label and legend
xlabel('\fontname{Times New Roman}Distance, mm')
ylabel('\fontname{Times New Roman}Amplitude, mm')
legend(['\fontname{Times New Roman}freq=',num2str(freq)],'Location','northeast');
%xlim([min(datax)-0.02*(max(datax)-min(datax)),max(datax)+0.02*(max(datax)-min(datax))]);
limfactor=0.2;
xlim([min(datax),max(datax)]);
ylim([min(datay)-limfactor*(max(datay)-min(datay)),max(datay)+limfactor*(max(datay)-min(datay))]);
% no margin or small margin
outerpos = ax.OuterPosition;
ti = ax.TightInset;
left = outerpos(1) + ti(1);
bottom = outerpos(2) + ti(2);
ax_width = outerpos(3) - ti(1) - ti(3);
ax_height = outerpos(4) - ti(2) - ti(4);
ax.Position = [left bottom ax_width ax_height];
% output picture now
%saveas(gcf,'C:\Users\admin\Desktop\p.emf')
saveas(gcf,'C:\Users\admin\Desktop\p.jpg')

Answers (1)

Sulaymon Eshkabilov
Sulaymon Eshkabilov on 1 Jun 2021
Hi,
Here is a simple answer:
...
exportgraphics(gcf,'p.png','Resolution',600)
  1 Comment
Simple Life
Simple Life on 2 Jun 2021
Thanks for your answer. It does't work at R2019a. Is there any way I can use exportgraphics at R2019a?

Sign in to comment.

Categories

Find more on Printing and Saving in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!