LEGEND Add Legent to Plot

Section: Handle-Based Graphics


This command adds a legend to the current plot. Currently, the following forms of the legend command are supported. The first form creates a legend with the given labels for the data series:

where 'label1' is the text label associated with data plot 1 and so on. You can also use the legend command to control the appearance of the legend in the current plot. To remove the legend from the current plot, use


To hide the legend for the current plot (but do not remove it)


And to show the legend that has been hidden, use


You can also toggle the display of the box surrounding the legend. Use




to turn the legend box off or on, respectively. To toggle the visible state of the current legend, use


Specifying no arguments at all (apart from an optional location argument as specified below) results in the legend being rebuilt. This form is useful for picking up font changes or relocating the legend.


By default, the legend command places the new legend in the upper right corner of the current plot. To change this behavior, use the 'location' specifier (must be the last two options to the command)


where option takes on the following possible values

This implementation of legend is incomplete relative to the MATLAB API. The functionality will be improved in future versions of FreeMat.