Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
270 views
in Technique[技术] by (71.8m points)

plot - MATLAB's exportgraphics ignores settings

I want to save a MATLAB plot with minimal white space around it. This should be possible with the exportgraphis function. However, this function seems to lack the possibility to specify the size.

plot(1:10);

set(gcf, 'PaperUnits', 'centimeters');
x = 5;
y = 5;
set(gcf, 'PaperPosition', [0 0 x y]);

saveas(gcf, 'test_saveas.png');
exportgraphics(gcf, 'test_exportgraphics.png');
exportgraphics(gcf, 'test_exportgraphics_resolution.png', 'Resolution', 50);

Based on my code, the plot should be saved with a size of 5x5 cm. This works for saveas, but not for exportgraphis. exportgraphis just saves with some other size (roughly 8x8 cm). Unfortunately, adding the 'Resolution', 50 in exportgraphis does not change the size of the picture but only the resolution.

To avoid any confusion between size and resolution: If you open test_exportgraphics.png and test_exportgraphics_resolution.png in a picture program, they look like they have a different size (due to the different resolution). However, if you copy them from the Windows Explorer and add them into a Microsoft Word, both have a similar same size (roughly 8x8 cm), just with a different resolution.

What I am looking for: How can I save a plot without this white space around it and still be able to specify the size so I can conveniently copy the plot from Windows Explorer into Word.

question from:https://stackoverflow.com/questions/66054869/matlabs-exportgraphics-ignores-settings

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...