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

조회 수: 18 (최근 30일)
Antonello Zito
Antonello Zito 2022년 3월 17일
댓글: Jan 2022년 3월 18일
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