Using exportgraphics on Figure With Multiple Subplots

86 visualizaciones (últimos 30 días)
I have a figure which has 1 x 3 subplots. I want to get a high resolution pdf file (for publication purposes) which contains all the subplots. However, when I use
>> exportgraphics('filename.pdf')
the pdf file created has only part of the figure. I would appreciate receiving advise on how to generate a high-resolution pdf file which contains the full figure (in this case, with 3 subplots). Thanks.

Respuesta aceptada

Johannes Hougaard
Johannes Hougaard el 8 de Jul. de 2021
What you need to do is to provide an input to exportgraphics to take the figure rather than the axes
When calling exportgraphics with no handle-style input it just exports 'gca' (the last active axes handle)
This should do the trick (using f as the figure handle but you could theoretically just use gcf as your input to exportgraphics)
filename = 'thisisadpdffile.pdf';
x = linspace(-pi*9,pi*9,999);
f = figure;
subplot(2,2,1);
plot(x,sin(x));
subplot(2,2,2);
plot(x,sin(x./2),'color',[155 0 0]/255);
subplot(2,2,[3 4]);
plot(x,cos(x));
hold on
plot(x,1./x);
exportgraphics(f,filename);

Más respuestas (0)

Categorías

Más información sobre Printing and Saving en Help Center y File Exchange.

Productos


Versión

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by