How do I export a figure so that it appears exactly the same as it does on screen?

21 次查看(过去 30 天)
When I use the PRINT command, the output does not appear exactly like the figure I had set up. Relative sizes and locations of lines, fonts, axis labels, tick marks, and annotations may be distorted.

采纳的回答

MathWorks Support Team
编辑:MathWorks Support Team 2023-5-31
There is no best method for exporting figures. Different techniques will produce varying results depending on the system and the figure being exported. The following lists some options to try if you are unsatisfied with your exported image.
1. Try changing the renderer . The available options are 'painters', 'OpenGL', or 'zbuffer'. For example:
hfig = figure; %this returns a handle to the figure
set(hfig, 'Renderer', 'painters')
2. Try both File -> Save As and the PRINT function with different file formats. In particular, you might want to try exporting the figure as a bitmap, if you have not already tried so.
Also, printing to pdf produces high quality images, but might not maintain the aspect ratios in your figure if the dimensions of your figure are too large.
Also, try file formats created both with MATLAB and Ghostscript.
You can see a list of available file formats and printing options in the documentation:
3. If the figure created and saved in MATLAB is a different size than the image imported into an external application, different objects in the image may rescale differently. Set up your figures to be the same size as in your final application.
4. Try the Export Setup under the File menu. This gives you the option of specifying properties such as fonts, resolution, and size. Note however that when you change the size of the figure, the legends will not scale accordingly. You will have to set the sizes of the legends manually.
5. Use GETFRAME and IMWRITE. For example:
hfig = figure;
%plot your data here
f = getframe(hfig);
imwrite(f.cdata, 'test.png', 'png')

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Graphics Object Properties 的更多信息

标签

尚未输入任何标签。

产品


版本

R2008b

Community Treasure Hunt

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

Start Hunting!

Translated by