Frame adjustment of a printed PNG file

2 vues (au cours des 30 derniers jours)
Mehmet  Emin
Mehmet Emin le 14 Déc 2015
Hi,
I have written a MATLAB code that prints out a plot as a PNG file. But I couldn't find how to adjust the outer frame of the PNG file, there's so much gap between the frame and axeses and I dont want to crop it everytime while I'm using it on MS office. So, I wonder if there is a way to solve this problem with some additional codes.
example code
.
.
.
figure(2);
set(gcf,'PaperUnits','centimeters'); % Printed figure properties
set(gcf,'PaperSize', [36 17]);
set(gcf,'PaperPosition',[0.1 0.1 35.8 16.8]);
plot(X,Z,'b-','LineWidth',2);
grid on
grid minor
title([i,' X-Z ']);
xlabel('X(m)');
ylabel('Z(m)');
Xmax11 = Xmax1 + mod(Xmax1,10000); % Tick gap
set(gca,'XTick',0:5000:Xmax11);
print ('-painters','-dpng','-r300',[i, ' X-Z.png']);
.
.
.
Thanks in advance

Réponses (1)

Nishant Kumar
Nishant Kumar le 14 Jan 2016
% Try this code
.
.
.
figure(2);
%set(gcf,'PaperUnits','centimeters'); % Printed figure properties
%set(gcf,'PaperSize', [36 17]);
%set(gcf,'PaperPosition',[0.1 0.1 35.8 16.8]);
plot(X,Z,'b-','LineWidth',2);
grid on
grid minor
title([i,' X-Z ']);
xlabel('X(m)');
ylabel('Z(m)');
Xmax11 = Xmax1 + mod(Xmax1,10000); % Tick gap
set(gca,'XTick',0:5000:Xmax11);
saveas(gcf,[i, ' X-Z.png']);
%print ('-painters','-dpng','-r300',[i, ' X-Z.png']);
.
.
.

Community Treasure Hunt

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

Start Hunting!

Translated by