It looks like a bug because the print function causes the get(h_icons(3),'FaceColor') to be changed from 'interp' back to 'flat'. Maybe it's from something in the legend function.
Bug with Legend object shading being reset during print
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
This produces a legend with an interpolated icon to better identify the surface, trivial here, but critical with many surfaces you want to print for publication.
figure(2); clf; Z=peaks; surf(Z); hold on; set(gcf,'PaperPositionMode','auto');
patch([-1; 1; 1; -1;]*25+25, [-1; -1; 1; 1;]*25+25,[1; 1; 1; 1;]+4,'EdgeColor','k','EdgeAlpha',0.6,'FaceAlpha',0.4,'LineStyle','--','FaceColor',[1 0 0])
set(gcf,'Position',[ 13 46 1249 556]); set(gcf,'Color',[1 1 1]);
[h,h_icons]=legend([{'peaks'},{'baseline'}]);
set(h_icons(3),'CData',[2 -10 2 10],'FaceColor','interp');
print(gcf,'-dpng',[cd '\BAD_flat_legend'],'-r300');
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
what it's supposed to look like
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/155123/image.png)
What actually prints
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/619888/image.png)
3 commentaires
Div Tiwari
le 8 Août 2016
I was unable to reproduce this in MATLAB R2016a with any of the graphics renderers. Could you tell me which release of MATLAB you're using?
Réponses (0)
Voir également
Catégories
En savoir plus sur Legend dans Help Center et File Exchange
Produits
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!