legendbar
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 (2026). legendbar (https://uk.mathworks.com/matlabcentral/fileexchange/6938-legendbar), MATLAB Central File Exchange. Retrieved .
MATLAB Release Compatibility
Platform Compatibility
Windows macOS LinuxCategories
Tags
Discover Live Editor
Create scripts with code, output, and formatted text in a single executable document.
| Version | Published | Release Notes | |
|---|---|---|---|
| 1.0.0.0 | More shorter |
