How to save graphs as vector images?

39 visualizaciones (últimos 30 días)
Nathan Robertson
Nathan Robertson el 27 de Mzo. de 2015
Comentada: Cool Symbol Fonts el 27 de Dic. de 2021
How do I save graphs as vector images and with custom image size? Right now I'm using print("gcf",-dpdf, "...") but I'm hoping there's a better function because I'm forced to create 8.5"x11" size images. The file format isn't important as long as it's a vector image format.
Thank you.
  1 comentario
Cool Symbol Fonts
Cool Symbol Fonts el 27 de Dic. de 2021
Highlights Logo Maker includes dozens of attractive layouts as well as other editing options for creating professional designs such as highlight cover, reel covers, logos, etc. Our Cover maker app lets you create eye-catching Instagram highlight covers to improve your IG profile.

Iniciar sesión para comentar.

Respuestas (2)

Richard Quist
Richard Quist el 30 de Mzo. de 2015
Editada: Richard Quist el 30 de Mzo. de 2015
The output size is controlled by the figure's PaperPosition property. PaperPosition is a 4 element vector that specifies an x- and y-offset (used only by "paged" formats like PDF, PostScript, and printing to paper), and a width and height. The units it uses is specified in the figure's PaperUnits property.
For example, if you want the figure to be 2" by 2" in the PDF file you would do something like this (specifying the width and height to use):
f = figure;
plot(rand(4))
% Specify that the image in the PDF should be 2x2
% My PaperUnits is inches
f.PaperPosition(3:4) = [2 2];
print -dpdf foo.pdf
With the above code the 2x2 image is placed on a full size page (8.5" x 11" for me). If you wanted the PDF to be sized so it was just big enough to hold the image, change the figure's PaperSize property to match the output size, and change the x- and y-offsets of the PaperPosition property to 0. Continuing the example from above:
% Make the "page" just big enough to hold the size output I want
f.PaperSize = [2 2];
% Specify that we start at the lower-left corner of the page
f.PaperPosition(1:2) = [0 0];
print -dpdf foo2.pdf
Because my PaperUnits are 'inches', this will put my plot onto a PDF file with a "page" that is 2" x 2".
See the the print command documentation: for more information on figure properties that affect printing/exporting.
Hope that helps.

John Zucker
John Zucker el 4 de Mayo de 2018
Hey, check the official document for saving and exporting graphics.
About customize size, do you mean by its dimension? If so, I know an simpler online app - DesignEvo that has vector and raster support but requires you to draw the graphics within the app.
Otherwise, if you mean the attribute size, I don't think there is a way to control the size. It's defined by the math and the software.

Categorías

Más información sobre Migrate GUIDE Apps en Help Center y File Exchange.

Productos

Community Treasure Hunt

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

Start Hunting!

Translated by