frudawski

saveplot

The saveplot function allows for easy figure export in Matlab and Octave.

Note 1: An empty function call will open a popup menu for saving the current figure.

Note 2: The function creates an invisible copy of the to be saved figure or axes. This might lead to different appearance of the saved figure. You can try the export_fig function from Matlab’s File Exchange as an alternative.

Usage:

file = saveplot(filename,'parameter','value')

Where:

ParameterDescription
fileReturns the full filename, char.
filename
(optional)
Defines the filename, char.
'handle'Refers to the axes or figure handle of the to be saved plot. E.g.:
f = figure
% plot something
saveplot(filename,’handle,’f)
In default mode, the saveplot function will save the current figure.
'fileformat'Defines the fileformat:
‘png’ (default), ‘eps’, ‘pdf’, ‘svg’, ‘jpg’, ‘tiff’, ‘bmp’
'resolution'Defines the resolution in dpi for pixel graphic formats, numeric, default: 300.
'papersize'Defines the size of the figure, vector: [width height]
'path'Set the path attribute to absolute or relative:
‘absolut’ absolut filename with full path (default)
‘relative’ relative filename starting at current folder
'popup'Enables or disables the the popup menu for saving the plot.
‘on’ a popup menu appears
‘off’ no popup menu appears and the plot is saved as specified in the filename.
'InvertHardcopy'‘on’ save the figure as is, including background colour and other things
‘off’ save the figure without background colour (default)
Note: The InvertHardcopy command might behave differently depending on the file format.

Examples

Save the current figure using a popup menu:

saveplot

Save the current figure as plot.pdf using a popup menu:

saveplot('plot.pdf','fileformat','pdf')

Save the current figure as plot.svg in the current folder without popup menu:

saveplot('plot','fileformat','svg','path','relative','popup','off')

Leave a comment

* I accept the use of cookies as well as the terms in the privacy policy. I accept that data provided by me is processed and saved. I know and accept that comments may be saved and published after review.