save figure in a certain size

174 visualizaciones (últimos 30 días)
Richard
Richard el 4 de Sept. de 2012
Editada: Pavan Kumar el 29 de Oct. de 2022
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?

Respuesta aceptada

Daniel Shub
Daniel Shub el 4 de Sept. de 2012
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])

Más respuestas (2)

Azzi Abdelmalek
Azzi Abdelmalek el 4 de Sept. de 2012
Editada: Azzi Abdelmalek el 4 de Sept. de 2012
%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 comentarios
Khairy Elsayed
Khairy Elsayed el 9 de En. de 2022
Thank you. It works well.
Pavan Kumar
Pavan Kumar el 29 de Oct. de 2022
Thanks!

Iniciar sesión para comentar.


Hej
Hej el 25 de En. de 2019
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 comentarios
KAE
KAE el 9 de Jul. de 2019
I have this same problem for a large figure (20x24")
Pavan Kumar
Pavan Kumar el 29 de Oct. de 2022
Editada: Pavan Kumar el 29 de Oct. de 2022
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

Iniciar sesión para comentar.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by