Impossible to print *really* vector plots when containing a lot of data
19 views (last 30 days)
Show older comments
Hi all!
So, as in the title, my general problem is that, when a plot to-be printed contains really a lot of data (e.g. many thousands of scatter points, or maybe a surface plot with high 2D data resolution) I am not able to print it as a real vector picture with the print command, even if I ask to save it in .eps or .pdf formats.
Experience tells me that it's something that really has to do with the "quantity" of data to be plotted. Look at the plots that I attached here in the .zip.
The first example is a scatter plot: very few points, plot correctly printed as a vector .eps. Using exactly the same code and only adding much more points (the smaller ones, like many thousands), the printed .eps is not vector anymore.
The second example is a 2D plot: only few simple lines, plot correctly printed as a vector .eps. Using exactly the same code and only adding on top a surface plot with quite high resolution (like 600x1200), the printed .eps is not vector anymore.
To me it really seems that the problem is in the printing, not in any other parts of the code. And I don't really understand why, it's just terribly annoying. A partial solution is to call figure.Renderer = 'Painters', and then adding a very high resolution in the print function (like '-r600' or '-r800'). But this does not really solve the problem as it just gives me a raster picture with high resolution (which consequently also tends to be quite heavy).
As simple as it is, I want such plots even with many data points to be really vector.
Any ideas? (Using MATLAB R2021b, but issue present also with previous versions)
5 Comments
Jan
on 18 Mar 2022
Alternative, as mentioned in my answer:
exportgraphics(f, 'default.eps'); % Pixel like
f.Renderer = 'painters'
exportgraphics(f, 'vector.eps'); % Better quality
I assume, this does the same internally.
Accepted Answer
Jan
on 17 Mar 2022
Edited: Jan
on 17 Mar 2022
Yes, your oberservation is correct. If the 'RendererMode' of the figure is set to 'auto', Matlab enables the OpenGL renderer if a lot of data are displayed. OpenGL creates pixels graphics, so an export of vector graphics is not possible.
Set the renderer manually to avoid this:
figure('Renderer', 'painters');
This sets the 'RendererMode' to 'manual' automatically.
0 Comments
More Answers (0)
See Also
Categories
Find more on Graphics Performance in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!