Overall size of subplot figure after tiff export
3 views (last 30 days)
Show older comments
Hello everyone,
With some frequencey I have to stack a couple of figures on a column. I have been doing this manually, but the subplot function would help a lot. The problem is that although I have found info about how to set the size of the individual subplots within one figure, I still did not managed to set the overall figure size after printing to tiff. I try to set the print size with the command "set(gcf, 'PaperPosition', [0.25 2.5 3.3 7]); print -dtiff -r600 temp.tif", but although this works nicelly without subplot, when I use subplot, it just generates its own width and height.
I post a simplified version of the code below. The goal is to have a tiff image with 3.3x7 inches; but what I get is 2.17x4.6 inches. Thanks!
xdata=[1:10];
ydata=[1:50:500];
ydata_std=[1:10:100];
subplot(3,1,1)
plot(xdata,ydata,'o','MarkerFaceColor',[1 0 0],'Color','k','MarkerSize',5);
axis([0.8 10.2 50 510])
set(gca,'XTick',(1:1:11),'YTick',([50 100 150 200 300 400 500]))
ylabel('\itD\rm_H / nm','FontSize',12,'FontName','Arial'); %\Delta
xlabel(' \it xdata','FontSize',12,'FontName','Arial');
subplot(3,1,2)
plot(xdata,ydata,'o','MarkerFaceColor',[1 0 0],'Color','k','MarkerSize',5);
axis([0.8 10.2 50 510])
set(gca,'XTick',(1:1:11),'YTick',([50 100 150 200 300 400 500]))
ylabel('\itD\rm_H / nm','FontSize',12,'FontName','Arial'); %\Delta
xlabel(' \it xdata','FontSize',12,'FontName','Arial');
subplot(3,1,3)
plot(xdata,ydata,'o','MarkerFaceColor',[1 0 0],'Color','k','MarkerSize',5);
axis([0.8 10.2 50 510])
set(gca,'XTick',(1:1:11),'YTick',([50 100 150 200 300 400 500]))
ylabel('\itD\rm_H / nm','FontSize',12,'FontName','Arial'); %\Delta
xlabel(' \it xdata','FontSize',12,'FontName','Arial');
set(gcf, 'PaperUnits', 'inches');
set(gcf, 'PaperPositionMode', 'manual');
set(gcf, 'PaperPosition', [0.25 2.5 3.3 7])
print -dtiff -r600 temp.tif
0 Comments
Accepted Answer
Jan
on 13 Mar 2021
Edited: Jan
on 13 Mar 2021
Which Matlab version are you using? With R2018b your code produces a TIFF with the Print Size 3.30 x 7.00 inches, exactly as you wanted. See the attached TIF image. The print size is shown in the properties of the file, e.g. with XNView. How do you determine the size 2.17x4.6 inches ?
More Answers (0)
See Also
Categories
Find more on Subplots in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!