Printing a scatterplot with '-depsc' results in a bitmap

I'd be grateful for help on this:
The commands
scatter([2,3],[3,2],10,[0.1 0.1 0.1;0.8 0.8 0.8],'o','filled');
print(gcf,'-depsc','test')
produce a 6 MB .eps-file, which is a bitmap, not a vector graphic. This seems to be a problem of the color definition.

 Risposta accettata

Some 3D plots set the Renderer of the figure to "OpenGL" or "ZBuffer", if the RendererMode is set to the default "auto". Then PRINT can export bitmaps only. So solve this, you can use the "Painters" renderer, but this can effect the display of the graphics, e.g. it cannot show transparent objects.
figure('Renderer', 'Painters'); % Sets RendererMode to 'manual' automatically
scatter([2,3],[3,2], 10, [0.1 0.1 0.1;0.8 0.8 0.8], 'o', 'filled');
print(gcf, '-depsc', 'test')
[EDITED] 30-Sept-2011 06:43
Updating Matlab will not help: The vector format EPS is a 2D format, such that e.g. the mutual intersection of triangles cannot be expressed and displayed correctly. The Painters renderer uses the order of creation to emulate the order in the Z-depth (direction orthogonal to the screen), which leads to nice results in many cases. Even the ZBuffer and OpenGL renderers cannot consider the real Z-order of objects, because this would require a geometrical understanding of the objects, e.g. the intersecting triangles. Therefore the Z-order of the pixels is used to create 3D-scenes, which appear to be realistic. But this has the drawback, that the information about the geometrical shapes is lost and cannot be retrieved by any tricks. I had success with using the 'v6' flag in 2011b:
scatter('v6', [2,3],[3,2], 10, [0.1 0.1 0.1;0.8 0.8 0.8], 'o', 'filled');
print(gcf,'-depsc','test')
This method is not documented and a warning appears. But the PRINT output is a vector format. I assume, that you can copy the relevant part from scatter.m and implement a non-warning method matching your needs. Not convenient, I know.
[EDITED 2] 30-Sept-2011 08:58 Is the SVG or STL export helpful?

8 Commenti

cheers, Jan.
Although this doesn't work on my Matlab Release 2008b("Warning: RGB color data not yet supported in Painter's mode"),
I'm finally aware of what causes the trouble.
Does anyone know a workaround for the problem, or do I have to install a more recent release?
Do you get the same error if you do not set the renderer property of the figure, but instead call print like this:
print(gcf, '-depsc','-painters', 'test')
Or if you call print as a command:
print -depsc -painters test.eps
This might look like silly suggestions - but I've had to do some other "silly" things when it comes to printing.
HTH
hi Bjoern,
your suggestions don't solve the problem. Both commands result in "Warning: RGB color data not yet supported in Painter's mode" and a print with empty axes.
See [EDITED].
Hi Jan,
using the 'v6' option solved my problem. Thank you very much!!
Timo
Please send this question & solution to the technical support. Perhaps they can stop the removing of the v6 option for SCATTER.
I just did.
Thanks for your help.
Matlab answered. See below.

Accedi per commentare.

Più risposte (2)

If everything fails, maybe you could stick with the open-gl/z-buffer renderer and simply remove all text decorations, and then fix things with psfrag or pstricks to fix things in latex. Or import the bitmap to some other vector-based drawing tool. This would be quite an annoyingly laborious route and something I thankfully never have had to do - but it might get the job done.
Timo
Timo il 6 Ott 2011
This is the answer of Matlabs Technical support to the initial problem:
"...
In order to print an image of the vector type the renderer of the figure with the image has to be set to “Painters”. However, by changing the renderer of the figure which is created using the SCATTER command the following warning is returned and the circles no longer appear on the SCATTER plot:
Warning: RGB color data not yet supported in Painter's mode. This is an issue with the way the patches store CData. The following makes a direct color mapping for each of the markers so that now “Painters” should be able to render the plot correctly and the PRINT command can produce a vector type image:
C=[0.1 0.1 0.1;0.8 0.8 0.8];
colormap(C)
scatter([2,3],[3,2],100,1:size(C,1),'o','filled');
print(gcf,'-depsc','-painters','myEps')
..."

1 Commento

Great, you learn something every day - or rather everyday I learn something useful is not completely wasted!
Does this "trick" to propagate true rgb-colours to the patches hit you performance wise in any noticeable way for big scatterplot? Less responsive, slower, something else?

Accedi per commentare.

Categorie

Scopri di più su Graphics Performance in Centro assistenza e File Exchange

Richiesto:

il 29 Set 2011

Community Treasure Hunt

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

Start Hunting!

Translated by