Pie with legend
I want to add legend to matlab pie instead of just putting the names close
the pie itself. That is, I want names to be displayed in a box, and the
percentage to be displayed close to the pie (as it usually is). But if I
simply add a legend, as follows, it will be not attached to the patches
information:
pieH=pie([.3,.4,.3]);
legend({'Leg1','Leg2','Leg3'},'location','EastOutside');
I've tried turning the patch annotation icon display to on, as follows,
but it didn't work:
set(get(get(pieH(1),'Annotation'),'LegendInformation'),'IconDisplayStyle','on')
set(get(get(pieH(3),'Annotation'),'LegendInformation'),'IconDisplayStyle','on')
set(get(get(pieH(5),'Annotation'),'LegendInformation'),'IconDisplayStyle','on')
I also tried passing the patched handles, as it says in the help, also
with no effect:
legend([pieH(1:2:end)],{'Leg1','Leg2','Leg3'},'location','EastOutside');
No comments:
Post a Comment