Painter's export problem

8 次查看(过去 30 天)
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

采纳的回答

Chad Greene
Chad Greene 2015-1-21
Painters does not support transparency. Can you set 'LineStyle' to 'none'?
  3 个评论
Mike Garrity
Mike Garrity 2015-1-21
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 2015-1-25
Yes, Chad's simple solution worked!

请先登录,再进行评论。

更多回答(1 个)

Francesco Carpanese
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

类别

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

Community Treasure Hunt

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

Start Hunting!

Translated by