save figure in a certain size

조회 수: 114 (최근 30일)
Richard
Richard 2012년 9월 4일
편집: Pavan Kumar 2022년 10월 29일
In the following figure:
data = rand(1,365);
subplot(121);
plot(1:365,data);
xlabel('label');
ylabel('label');
subplot(122);
plot(1:365,data);
xlabel('label');
ylabel('label');
How could I save this figure as a pdf where the dimensions of the figure i.e. including both subplots is 7.25 x 9.125 inches?

채택된 답변

Daniel Shub
Daniel Shub 2012년 9월 4일
You will probably want to use FEX:export_fig. Assuming your monitor is bigger than 7.25x9.125 inches, you just need to set the figure and paper size to be 7.25x9.125
set(gcf, 'Units', 'Inches', 'Position', [0, 0, 7.25, 9.125], 'PaperUnits', 'Inches', 'PaperSize', [7.25, 9.125])

추가 답변 (2개)

Azzi Abdelmalek
Azzi Abdelmalek 2012년 9월 4일
편집: Azzi Abdelmalek 2012년 9월 4일
%add this at the end of your code
set(gcf, 'PaperUnits', 'inches');
x_width=7.25 ;y_width=9.125
set(gcf, 'PaperPosition', [0 0 x_width y_width]); %
saveas(gcf,'fig1.pdf')
  댓글 수: 3
Khairy Elsayed
Khairy Elsayed 2022년 1월 9일
Thank you. It works well.
Pavan Kumar
Pavan Kumar 2022년 10월 29일
Thanks!

댓글을 달려면 로그인하십시오.


Hej
Hej 2019년 1월 25일
Hi I had the same questions, but the figure I get comes with a background white box that fits with the dimension and my actual figure is smaller. How do I remove this white box and make sure my figure is saved in the prescribed dimension? Thanks
  댓글 수: 2
KAE
KAE 2019년 7월 9일
I have this same problem for a large figure (20x24")
Pavan Kumar
Pavan Kumar 2022년 10월 29일
편집: Pavan Kumar 2022년 10월 29일
An alternate solution is to save the figure as EPS instead of saving as PDF, which gets rid of the white space in my case

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Contour Plots에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by