Painter's export problem

8 Ansichten (letzte 30 Tage)
Phil Dixon
Phil Dixon am 21 Jan. 2015
Bearbeitet: Walter Roberson am 13 Mai 2018
Dear Matlab central users,
I have created the following patch object:
Faces =[1 2 3 4; 5 6 7 8;9 10 11 12;13 14 15 16];
Verts = [-1 1;0 1;0 2;-1 2;0 1;1 1;1 2;0 2;1 1;2 1;2 2;1 2;2 1;3 1;3 2;2 2];
AV_color = [ 1 1 1;0 0.05 1;0.5 0.05 1;1 1 1];
figure
pch = patch('Faces',Faces,'Vertices',Verts,'FaceColor','flat','FaceVertexCData',AV_color,...
'EdgeAlpha',0,'FaceAlpha',1);
rgb_colors = get(pch,'CData');
[i,map] = rgb2ind(rgb_colors,64);
set(pch,'CData',double(i));
colormap(map);
Unfortunately, black edges appear around each figure upon painters rendering:
set(gcf, 'Renderer', 'painters');
I need the edges to be the same color as the faces. How can this be done?
Thanks,
Phil

Akzeptierte Antwort

Chad Greene
Chad Greene am 21 Jan. 2015
Painters does not support transparency. Can you set 'LineStyle' to 'none'?
  3 Kommentare
Mike Garrity
Mike Garrity am 21 Jan. 2015
Painters does support transparency as of MATLAB version R2014b. Except for the case of exporting to Postscript or EPS because those formats don't support it.
But as Chad said, if you're only using alpha of 0 or 1, then you might be better off using LineStyle=none. I would expect the graphics system to recognize that they're the same, but the LineStyle approach is a bit simpler.
Phil Dixon
Phil Dixon am 25 Jan. 2015
Yes, Chad's simple solution worked!

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (1)

Francesco Carpanese
Francesco Carpanese am 13 Mai 2018
A possible solution to fake transparency in .eps file is to properly stack the plots you would like to display, being careful to have the patch in the bottom.
plot([0,1], [0,1])
h = patch([0. 1. 1. 0.], [max(ylim) max(ylim) 0 0] , 'y', 'Linestyle', 'none', 'EdgeColor', 'none', 'Facecolor', 'g', 'FaceAlpha', 0.2);
% This is needed to bring patch to the buttom and fake the alpha.
uistack(h, 'bottom')
% Need to specify '-painters'
print('file_test','-painters','-depsc2')
% code
ends

Community Treasure Hunt

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

Start Hunting!

Translated by