How can i export figure with all bold axes saved?

1 次查看(过去 30 天)
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')

回答(1 个)

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

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Printing and Saving 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by