Print figure to pdf -- file size too large

28 ビュー (過去 30 日間)
Tom
Tom 2015 年 2 月 26 日
コメント済み: Tom 2015 年 3 月 23 日
Hello,
I have a function which creates a plot that has roughly 500,000 data points on it. When I print this figure to a pdf and open the pdf file it takes slightly longer to open than a less complex plot (meaning less data points). A colleague of mine uses the same function to generate the same plot and print to pdf; when he opens this pdf file it may take 5 minutes to display the plot.
He can send me the pdf file generated on his machine and it still takes longer than expected to open the file on my machine.
I was under the impression that when printing to a pdf I was essentially saving an image. Why would a complex plot with more data points take longer to open (as a pdf) than a plot with less data on it if this is true?
Problem is occurring on a Windows 64-bit machine running Matlab 2014b. I am using a Windows 64-bit machine running Matlab 2013b.
I have tried specifying the resolution '-r300' but that does not seem to make a difference.
Is there a different way I can save this figure to a pdf file to avoid this problem?
I have included some sample code which reproduces the results:
t = linspace(0,10,500000);
A = 10;
for i=1:length(t)
x(i) = A*sin(40*pi*t(i))+rand(1)/2;
y(i) = A*cos(40*pi*t(i))+rand(1)/2;
end
hf = figure;
plot(x,y,'linewidth',2);
grid on
title('200 Circles','fontweight','bold','fontsize',14)
xlabel('x','fontweight','bold','fontsize',14)
ylabel('y','fontweight','bold','fontsize',14)
print(hf,'-dpdf','Test_plot.pdf')
Thanks for the help!
-Tom-

採用された回答

Richard Quist
Richard Quist 2015 年 3 月 21 日
編集済み: Richard Quist 2015 年 3 月 21 日
I would guess that the PDF is being saved with an embedded image in 13b, and as a fully vectorized file in 14b. Try adding '-opengl' to your print command to force the use of the OpenGL renderer which will embed the figure as an image.
print(hf,'-dpdf','Test_plot.pdf', '-opengl')
Rich
  1 件のコメント
Tom
Tom 2015 年 3 月 23 日
Rich,
Thanks! It looks like this is just what I was looking for.
Cheers,
-Tom-

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File Exchange2-D and 3-D Plots についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by