File Exchange

image thumbnail

arnauddevie/simpleF​igureExport

version 1.0.0.0 (1.38 MB) by Arnaud Devie
Save the figure you want, in the dimensions you want, in the format(s) you want. Simply...

264 Downloads

Updated 26 Aug 2015

From GitHub

View license on GitHub

This is a Matlab function which can be used to save a figure in a variety of formats at once with full control of the figure dimensions and resolution.
I grew tired out Matlab lax interpretation of my 'PaperSize', 'PaperPosition' and 'Position' settings which inevitably produced unreliable output where actual dimensions of the figure do not match the target dimensions.
This function will be particularly useful to you for producing publication-ready graphics in a reliable yet simple fashion. Using this function, you are in control of the figure width, ratio, resolution, font size, font name, font weight. Bonus feature: the axes use as much room as possible to ensure maximum readability of the content.
Here is the call (variables are pretty self explanatory, send me a comment if you need help):
function [figureHandle] = simpleFigureExport (figureHandle, fileName, fileFormats, resolutionDPI, figureUnits, figureWidth, figureRatio, fontSize, fontName, fontWeight)
Here is how you can use it:
myfig_handle = simpleFigureExport (gcf, 'myfig', {'svg', 'tiff', 'jpeg', 'fig'}, 300, 'centimeters', 12, 4/3, 9, 'Arial', 'normal');

You will get, in your current directory, 4 files of the current figure (gcf) with a width of 12cm, a 4/3 ratio, an Arial police for all the text, and a 9-point font size. In this example, the file types will be *.svg, *.tiff, *.jpg and *.fig (the native Matlab file format for later re-use).

The beauty is that you can request multiple file formats at once (using the cell {} declaration in the example above), but also get a single file in the format of your choice, as in the example below.

myfig_handle = simpleFigureExport (gcf, 'myfig', 'jpeg', 300, 'centimeters', 12, 4/3, 9, 'Arial', 'normal');

All available file formats are listed at this address:

http://www.mathworks.com/help/matlab/ref/print.html?s_tid=srchtitle#inputs

Scientific journals often require a particular file format, minimum resolution and minimum font size. You can fulfill all these requirements by using the simple Figure Export function. Simply input the desired print size width of your graphics, the resolution in DPI, the font size and name and the file format.

In your output file(s), the resolution (DPI, dots per inch) can be double checked by dividing the number of pixels by the "physical" dimensions in the unit you specified. In this example, the requested width is 9 cm which equals to 3.543 in. The files are 1417 pixels wide which comes down to 1417/3.543 = 300 dpi.
Caution: your operating system may say otherwise but numbers don't lie (run your numbers if in doubt).

I hope you save a lot of time using this function and please contribute comments and improvements if you feel so inclined.

* Works with 2D graphs *

Cite As

Arnaud Devie (2021). arnauddevie/simpleFigureExport (https://github.com/arnauddevie/simpleFigureExport), GitHub. Retrieved .

MATLAB Release Compatibility
Created with R2006a
Compatible with any release
Platform Compatibility
Windows macOS Linux

Community Treasure Hunt

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

Start Hunting!
To view or report issues in this GitHub add-on, visit the GitHub Repository.
To view or report issues in this GitHub add-on, visit the GitHub Repository.