Impossible to print *really* vector plots when containing a lot of data

10 次查看(过去 30 天)
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 个评论
Antonello Zito
Antonello Zito 2022-3-17
This worked, thanks a lot! Or, better, both putting 'ContentType','vector' in exportgraphics or simply '-vector' in print, worked.
Jan
Jan 2022-3-18
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.

请先登录,再进行评论。

采纳的回答

Jan
Jan 2022-3-17
编辑:Jan 2022-3-17
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 个)

类别

Help CenterFile Exchange 中查找有关 Graphics Performance 的更多信息

产品


版本

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by