File Exchange

image thumbnail


version (3.2 KB) by Alexander Mering
Add as many legend you want to a single figure


Updated 27 Sep 2013

View License

This function allows to add multiple legends to a single figure / axes.

Simply define the typical legend properties such as DisplayName, LineStyle, Color, ... and there you go.

All additional settings such as Orientation, Location, ... could be freely choosen for each of the extra legends.

The contained examlpe shows the "ordinary" legend together with three additional legends.

Cite As

Alexander Mering (2020). AddMultipleLegends (, MATLAB Central File Exchange. Retrieved .

Comments and Ratings (2)


Exactly what I needed. However:
1) I don't want to plot the standard legend, so I added "legend off" after line 92
2) I had to set to 'on' the Visibility in this line: set(allchild(second_axes_handle(legend_num)),'Visible','on'). Otherwise I get the legend a bit greyish-shaded.

p kung

very good.

matlab's legend is pretty awkward; this routines helps; it allows adding legend of some selected plot handles without disturbing the existing legend/

the only thing is i wish the setup is a little simpler tho


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