Frame adjustment of a printed PNG file
3 views (last 30 days)
Show older comments
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.
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/152636/image.png)
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
0 Comments
Answers (1)
Nishant Kumar
on 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']);
.
.
.
0 Comments
See Also
Categories
Find more on Annotations 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!