Ask an expert. Trust the answer.

Your academic and career questions answered by verified experts

matlab : suppress legend entry without removing from Plot Browser

Date: 2022-12-01 12:39:38

One can suppress a legend entry for a line object h by executing h.HandleVisibility='off' or h.Annotation.LegendInformation.IconDisplayStyle='off'. However, both actions also prevent the curve from appearing in Matlab's Plot Browser user interface, and thus display of the curve cannot be interactively toggled.

Is there any way to suppress a legend entry for a given curve without also removing the ability to toggle display of that curve in the Plot Browser user interface? 

Answers: 

You can also turn off handle visibility. This is way easier than having to set every plot as h1 = ...

Example: 

 

x1 = randperm(10); y = randperm(10); x2 = randperm(10); plot(x1, y, '-', 'Color', 'black', 'HandleVisibility', 'off') hold on plot(x2, y, '-', 'Color', 'green', 'DisplayName', 'Put This In Legend') lgd = legend; set(lgd, 'Location', 'best') 

 


Why Matlabhelpers ?

Our Matlab assignment helpers for online MATLAB assignment help service take utmost care of your assignments by keeping the codes simple yet of high-quality. We offer the most reliable MATLAB solutions to students pursuing their Computer Science course from the Monash University, the University of Sydney, the University of New South Wales, the University of Melbourne; to name a few. Approach us today for best Matlab solutions online!

whatsApp order on matlabhelpers.com

telegram order on matlabsolutions.com