Effacer les filtres
Effacer les filtres

Painter's export problem

8 vues (au cours des 30 derniers jours)
Phil Dixon
Phil Dixon le 21 Jan 2015
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

Réponse acceptée

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

Connectez-vous pour commenter.

Plus de réponses (1)

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