I wish to use a stacked bar graph and specify my own colors. Have do I make the colors in the legend match the bar? thanks
data2D = rand(10,6);H=bar(data2D, 'stack');P=findobj(gca,'type','patch');myC= [0 0 1 1 0 0 1 0.4 0 0 0.8 1 0.6 0 1 0 1 0 ];for n= 1 : length(P) set(P(n),'facecolor',myC(n,:));endAX=legend(H, {'a','b','c','d','e','f'}, 'Location','Best');LEG = findobj(AX,'type','text');set(LEG,'FontSize',8);
Best Answer