legendbar

Places your items in legend in just same way as they stacked in bar.
1.3K Downloads
Updated 9 Mar 2005

No License

LEGENDBAR places your items in legend in just same way as they stacked in bar, from the first item at lowest place up to last item at highest place.

Don't forget to write the corresponding strings in opposite order as well!

Example: the same as in "help legend"

but here legend looks much nicer:

x = 0:.2:12;
plot(x,bessel(1,x),x,bessel(2,x),x,bessel(3,x));
legend('First','Second','Third');
legend('First','Second','Third',-1)

b = bar(rand(10,5),'stacked'); colormap(summer); hold on
x = plot(1:10,5*rand(10,1),'marker','square','markersize',12,...
'markeredgecolor','y','markerfacecolor',[.6 0 .6],...
'linestyle','-','color','r','linewidth',2); hold off
legend([legendbar(b),x],'Cucumbers','Green Beans','Peppers',...
'Peas','Carrots','Eggplant')

Cite As

Isabella Osetinsky-Tzidaki (2024). legendbar (https://www.mathworks.com/matlabcentral/fileexchange/6938-legendbar), MATLAB Central File Exchange. Retrieved .

MATLAB Release Compatibility
Created with R11
Compatible with any release
Platform Compatibility
Windows macOS Linux

Community Treasure Hunt

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

Start Hunting!
Version Published Release Notes
1.0.0.0

More shorter