How can i export figure with all bold axes saved?
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
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')
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/638085/image.jpeg)
0 Kommentare
Antworten (1)
Sulaymon Eshkabilov
am 1 Jun. 2021
Hi,
Here is a simple answer:
...
exportgraphics(gcf,'p.png','Resolution',600)
Siehe auch
Kategorien
Mehr zu Printing and Saving finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!