File Exchange

image thumbnail

legappend

version 2.0.1 (43.4 KB) by Samantha Kulpinski
Add or delete entries to a legend.

21 Downloads

Updated 20 Oct 2020

View Version History

View License

legappend appends new entries to the end of a legend by deleting the current legend and recreating a new, similar legend.

Syntax
legappend('new legend entry')
legappend('new entry 1','new entry 2',...,'new entry N')
legappend('')
legappend('','',...,'')
[legend_h,object_h,plot_h,text_strings] = legappend(...)

Description
legappend('new legend entry') appends an existing legend with "new legend entry".
legappend('new entry 1','new entry 2',...,'new entry N') adds several new entries to the legend.
legappend('') deletes the last entry from the legend.
legappend('','',...,'') deletes the last several entries from the legend.
[legend_h,object_h,plot_h,text_strings] = legappend(...) returns legend_h, the handle of the new legend; object_h, handles of the line, patch, and text graphics objects used in the legend; plot_h, handles of the lines and other objects used in the plot; and text_strings, a cell array of the text strings used in the legend. Note that for new legend entries, legappend does not add entries to a current legend, but deletes the current legend and recreates a new one. As a result, the legend handle will change with each new-entry use of legappend. The legend handle does not change when legappend is used to delete an entry.


Author Info
Version 2 of this script was written by Samantha Kulpinski of General Electric, October 2020. Example scripts were written for the original version of this code by Chad A. Greene.
The original version of this function was created by Chad A. Greene of the Institute for Geophysics, The University of Texas at Austin, July 2014.

Cite As

Samantha Kulpinski (2021). legappend (https://www.mathworks.com/matlabcentral/fileexchange/81438-legappend), MATLAB Central File Exchange. Retrieved .

Comments and Ratings (2)

VAIBHAV DESHMUKH

Works as expected with 2020a version. I wish Matlab had this by default. Thank you so much!

inaam abbas

MATLAB Release Compatibility
Created with R2020b
Compatible with any release
Platform Compatibility
Windows macOS Linux
Tags Add Tags
Acknowledgements

Inspired by: legappend

Community Treasure Hunt

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

Start Hunting!

legappend