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

31 views (last 30 days)
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.

Accepted Answer

MathWorks Support Team
MathWorks Support Team on 31 May 2023
Edited: MathWorks Support Team on 31 May 2023
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')

More Answers (0)

Categories

Find more on Graphics Object Properties in Help Center and File Exchange

Tags

No tags entered yet.

Products


Release

R2008b

Community Treasure Hunt

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

Start Hunting!