Printing Figure to PDF produces bitmap instead of vector

25 vues (au cours des 30 derniers jours)
Jelmer Hoogendoorn
Jelmer Hoogendoorn le 8 Mar 2011
Commenté : Johnny Zheng le 21 Sep 2020
Hi,
I've three figures that I save to a pdf for inclusion in my report. For this i user: print(h,'-dpdf',filename); where h is the handle of the figure. All figures are plotted with the plot command, although the first image is just a combination of lines. While the other two are actually scatterplots, but plotted with the plot command for speed. Now with the print command the first figure is correctly saved as a a vector image, while the other two are bitmaps.
How is this possible? And how can I prevent this/correct this?
Thanks,
ChoKamir

Réponse acceptée

Jan
Jan le 8 Mar 2011
Check the 'Renderer' property of the figures: While figures drawn by the 'Painters' renderer are vector plots in the exported PDF, with 'OpenGL' and 'ZBuffer' the PDF contains bitmap pictures of the screen output.
Either you have defined the renderer manually, or it was set automatically by Matlab, if the 'RendererMode' of the figure is 'auto'.
Solution: Set the renderer manually to 'Painters'.
  3 commentaires
LeChat
LeChat le 7 Mar 2017
Modifié(e) : LeChat le 7 Mar 2017
fig1=figure(1);
fig1.Renderer='Painters';
Thank you Jan!
neuromechanist
neuromechanist le 1 Sep 2017
Modifié(e) : neuromechanist le 1 Sep 2017
But the point is graphics provided by Painters is nothing that can be compared to OpenGL rendering. I am back to OpenGL until I need to modify a figure in Vector environment. But for presenting figures AsIs, Painters is not a good choice.

Connectez-vous pour commenter.

Plus de réponses (2)

Matlabber 1.0
Matlabber 1.0 le 6 Mar 2018
Modifié(e) : Matlabber 1.0 le 6 Mar 2018
in case you are using surf() plots, make sure you don't use too many points. the following code shows how surf makes the saved pdf become a bitmap aboe 180x180 points:
function TestVectorGraph
h=figure(1);clf;
for k=178:185
xrange=linspace(0,1,k+1);
yrange=linspace(0,1,k+1);
[x,y]=ndgrid(xrange,yrange);
surf(x,y,x.^2+y.^2);
fname=sprintf('Testvector%03d.pdf',k)
print(fname,'-dpdf')
end
end
anybody knows more about this? i guess it's for file size reasons.
  1 commentaire
Katrina Deane
Katrina Deane le 8 Juin 2019
Modifié(e) : Katrina Deane le 8 Juin 2019
Hi there,
I came here for this exact reason so thank you!
I just tried Jan's solution above and it seems that manually changing the renderer to Painters overrides this so that it's vector.
I'm guessing you're right about size reasons, because now my design software is having difficultly handling so many objects.

Connectez-vous pour commenter.


Aleksey Dyskin
Aleksey Dyskin le 11 Sep 2018
Hi Jan,
despite the fact that I use
fig1=figure(1)
fig1.Renderer='Painters';
to set the renderer, when I print the figure to PDF, it still remains in bitmap... Any ideas of what can be a reason for it? Thank you!
  1 commentaire
Johnny Zheng
Johnny Zheng le 21 Sep 2020
Good idea! Don't know if MATLAB developer will see this Q&A.

Connectez-vous pour commenter.

Catégories

En savoir plus sur Graphics Performance dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by