Print figure to pdf -- file size too large

15 次查看(过去 30 天)
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 CenterFile Exchange 中查找有关 Lighting, Transparency, and Shading 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by