How to save graphs as vector images?

62 ビュー (過去 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;
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 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.

カテゴリ

Help Center および File ExchangePrinting and Saving についてさらに検索

製品

Community Treasure Hunt

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

Start Hunting!

Translated by