Legend patch color changes when hgexport

4 views (last 30 days)
Edward Byers
Edward Byers on 15 Apr 2014
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

Answers (0)

Community Treasure Hunt

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

Start Hunting!