Legend patch color changes when hgexport

1 回表示 (過去 30 日間)
Edward Byers
Edward Byers 2014 年 4 月 15 日
Hi I have manually changed patch colors in the legend to suit my preferences, but when I run hgexport at the end to export the file into .eps, the colors switch back. I am using a function called 'plotBarStackGroups'
plotBarStackGroups(d(:,:,1:15),{1:6}) %Function for plotting grouped and stack bar charts (3-d dataset
lg=legend('a','b','c','location','northwest'); % Create legend
lgp=findobj(lg,'type','patch'); %Find the legend patches (only 3)
cm=[0 1 0; 0 0.8 1; 0 0 1]; % define Colors
set(lgp(1),'facecolor',cm(1,:)); %Manually change the patch colors
set(lgp(2),'facecolor',cm(2,:));
set(lgp(3),'facecolor',cm(3,:));
hgexport(gcf,'fig.eps') % Export figure into .eps
To be noted, is that the switch back also occurred previously, when I had used the command:
set(gca,'fontsize',11)
To resolve this I moved this command above the color switch, but obviously cannot do this with the export function! Many thanks

回答 (0 件)

カテゴリ

Help Center および File ExchangeLegend についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by