Clear Filters
Clear Filters

How to export clean and high resolution images for figures

90 views (last 30 days)
Dear community,
I have the figures in the format of ".fig", and when I export them in the form of ".eps", they appear a bit foggy, and their quality is not good enough to submit them for publication. What is the best option to obtain high-quality images for figures and graphs in Matlab? by using the option export as
Thanks

Accepted Answer

Image Analyst
Image Analyst on 22 Jul 2023
There are several methods to save figures. Did you use the menu bar or pull down menu on the figure itself? I'm not sure what that uses. But you might try these options from a script or the command line.
  1. exportgraphics
  2. saveas
  3. print
  5 Comments
Image Analyst
Image Analyst on 22 Jul 2023
help exportgraphics
EXPORTGRAPHICS Save plot or graphics content to file EXPORTGRAPHICS(OBJ, FILESPEC) saves the specified graphics to a file. OBJ is the handle of any type of an axes, a figure, a chart that can be a child of the figure, a tiled chart layout, or a container within the figure. FILESPEC is a character vector or string scalar specifying the name of a file to create. It must include the extension, and can optionally include a full or relative path. EXPORTGRAPHICS supports creating JPEG, PNG, and TIFF images, and EPS, PDF, and EMF vector formats (EMF is only supported on Windows). EXPORTGRAPHICS(___, OPTIONS) saves the graphics to the file, applying the specified OPTIONS. OPTIONS is one or more of the following name-value pairs. 'ContentType', CONTENTTYPE how to generate content in vector format files CONTENTTYPE can be one of the following values - 'vector' to generate vectorized (scalable) output - 'image' to generate rasterized output (embed image) - 'auto' allow MATLAB heuristic to decide The default value is 'auto' 'Resolution', DPI specifies output resolution for images. DPI must be a positive whole number. The default value is 150 'BackgroundColor', COLORSPEC specifies the color to use as the background COLORSPEC can be one of the following values - a color name, such as 'red', or 'w' - an RGB triplet, such as [1 0 0] or [1 1 1] - a hexadecimal color code, such as '#FFF' or '#FFFFFF') - 'none' to use either a white or transparent background, depending on what the output format supports - 'current' to use the graphic's current background color The default value is 'white' 'Colorspace', COLORSPACE the color space to use when generating output COLORSPACE can be one of the following values - 'rgb' generates RGB true color output - 'gray' generates grayscale output - 'cmyk' generates cyan, magenta, yellow, black output The default value is 'rgb' 'Append', APPEND specifies whether to append the output to an existing file or replace the content. APPEND can have a value of true or false. - true appends the output to an existing file - false replaces the content in an existing file The default value is false Example: Export a plot to a pdf file plot(rand(3)); exportgraphics(gca, 'results.pdf'); Example: Export a plot to a pdf file and ensure output is vectorized/scalable plot(rand(3)); exportgraphics(gca, 'results.pdf', 'ContentType', 'vector'); Example: Export a plot as an image to a pdf file plot(rand(3)); exportgraphics(gca, 'results.pdf', 'ContentType', 'image'); Example: Export a plot and append to an existing pdf file plot(rand(3)); exportgraphics(gca, 'results.pdf', 'Append', true); Example: Export a specific plot from the figure fig = figure; ax1 = subplot(2,1,1); bar(magic(4)); ax2 = subplot(2,1,2); plot(rand(4)); exportgraphics(ax2, 'results.png'); Example: Export all plots from figure to an image file at 300DPI subplot(2,1,1); bar(magic(4)); subplot(2,1,2); plot(rand(4)); exportgraphics(gcf, 'results.png', 'Resolution', 300); Example: Export a plot to an image file with a red background plot(rand(3)); exportgraphics(gca, 'results.png', 'BackgroundColor', [1 0 0]); Example: Export a plot to a grayscale image file plot(rand(3)); exportgraphics(gca, 'results.png', 'Colorspace', 'gray'); See also COPYGRAPHICS, EXPORTAPP Documentation for exportgraphics doc exportgraphics
help saveas
SAVEAS Save Figure or Simulink block diagram in desired output format SAVEAS(H,'FILENAME') Will save the Figure or Simulink block diagram with handle H to file called FILENAME. The format of the file is determined from the extension of FILENAME. SAVEAS(H,'FILENAME','FORMAT') Will save the Figure or Simulink block diagram with handle H to file called FILENAME in the format specified by FORMAT. FORMAT can be the same values as extensions of FILENAME. The FILENAME extension does not have to be the same as FORMAT. The specified FORMAT overrides FILENAME extension. Valid options for FORMAT are: 'fig' - save figure to a single binary FIG-file. Reload using OPEN. 'm' - save figure to binary FIG-file, and produce callable MATLAB code file for reload. 'mfig' - same as M. 'mmat' - save figure to callable MATLAB code file as series of creation commands with param-value pair arguments. Large data is saved to MAT-file. Note: MMAT Does not support some newer graphics features. Use this format only when code inspection is the primary goal. FIG-files support all features, and load more quickly. Additional FORMAT options include devices allowed by PRINT. NOTE: not all format options are allowed for Simulink block diagrams. See the online help for more information. Examples: Write current figure to MATLAB fig file saveas(gcf, 'output', 'fig') Write current figure to windows bitmap file saveas(gcf, 'output', 'bmp') Write block diagram named 'demo' to an Encapsulated Postscript file saveas(get_param('demo', 'Handle'), 'output', 'eps') In the following list, SAVE_SYSTEM is available for Simulink users only. See also LOAD, SAVE, OPEN, PRINT, SAVE_SYSTEM, EXPORTGRAPHICS. Documentation for saveas doc saveas
help print
PRINT Print or save a figure or model. A subset of the available options is presented below. For more details see the documentation. PRINT, by itself, prints the current figure to your default printer. Use the -s option to print the current model instead of the current figure. print % print the current figure to the default printer print -s % print the current model to the default printer PRINT(filename, formattype) saves the current figure to a file in the specified format. Vector graphics, such as PDF ('-dpdf'), and encapsulated PostScript ('-depsc'), as well as images such as JPEG ('-djpeg') and PNG ('-dpng') can be created. Use '-d' to specify the formattype option print(fig, '-dpdf', 'myfigure.pdf'); % save to the 'myfigure.pdf' file The full list of formats is documented here. PRINT(printer, ...) prints the figure or model to the specified printer. Use '-P' to specify the printer option. print(fig, '-Pmyprinter'); % print to the printer named 'myprinter' PRINT(resize,...) resizes the figure to fit the page when printing. The resize options are valid only for figures, and only for page formats (PDF, and PS) and printers. Specify resize as either '-bestfit' to preserve the figure's aspect ratio or '-fillpage' to ignore the aspect ratio. The documentation contains additional details and examples, including how to specify the figure or model to print, adjust the output size and resolution, save to the clipboard, and specify the renderer to use. See also SAVEAS, PRINTPREVIEW, SAVEFIG, EXPORTGRAPHICS, COPYGRAPHICS. Documentation for print doc print Other uses of print arima/print matlab.automation.streams.OutputStream/print matlab.automation.streams.ToStandardOutput/print simscape.logging.Node/print

Sign in to comment.

More Answers (0)

Categories

Find more on Printing and Saving in Help Center and File Exchange

Products

Community Treasure Hunt

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

Start Hunting!