How can i export figure with all bold axes saved?

1 回表示 (過去 30 日間)
Simple Life
Simple Life 2021 年 6 月 1 日
コメント済み: Simple Life 2021 年 6 月 2 日
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
Sulaymon Eshkabilov 2021 年 6 月 1 日
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 Center および File ExchangePrinting and Saving についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by