How to Remove an Entry From the Legend on MATLAB

Written by joe friedman | 13/05/2017

MATLAB is an incredibly useful mathematics and engineering software tool capable of performing advanced calculations and engineering simulations. One of its most useful purposes is plotting data into 2D and 3D figures. On graphs with multiple lines or bars of data, a legend is useful to define data series. However, you might not want every data series to appear in the legend. MATLAB does not offer a straightforward way to remove an entry in a legend, but it is possible to do so if you follow a few steps.

Click on the button that looks like a mouse pointer in the figure toolbar to enable editing of the plot.

Click on a data series line or bar to select it.

Go back to MATLAB's command line and type the following:

hasbehavior(gco, 'legend', false);

Return to the figure and right-click on the legend. Click "Refresh," and the legend entry for the line or bar selected in Step 2 will disappear from the legend.

  • All types
  • Articles
  • Slideshows
  • Videos
  • Most relevant
  • Most popular
  • Most recent

No articles available

No slideshows available

No videos available

By using the site, you consent to the use of cookies. For more information, please see our Cookie policy.