How to save graphs as vector images?

조회 수: 34 (최근 30일)
Nathan Robertson
Nathan Robertson 2015년 3월 27일
댓글: Cool Symbol Fonts 2021년 12월 27일
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
Cool Symbol Fonts
Cool Symbol Fonts 2021년 12월 27일
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.

댓글을 달려면 로그인하십시오.

답변 (2개)

Richard Quist
Richard Quist 2015년 3월 30일
편집: Richard Quist 2015년 3월 30일
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;
% 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 2018년 5월 4일
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.


Community Treasure Hunt

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

Start Hunting!

Translated by