How to make the legend selective?
Afficher commentaires plus anciens
I have a bunch of algorithms I am testing for statistical significance. I wrote a script to generate and save plots which I can publish in my thesis using Latex.
The problem is shown in the figures below-


In the first figure since the first three quantities satisfy significance criteria the legend is all nice and good, but in the second figure since the third one is not significant the legend uses the marker style being used for non significant data points.
How can I correct it such that the color and marker styles remain consistent in the legend. It is important that this is a generalized solution since I am always adding data and the levels of significance may change.
Réponse acceptée
Plus de réponses (1)
Sebastian Castro
le 23 Avr 2015
Modifié(e) : Sebastian Castro
le 23 Avr 2015
You can specify the graphics objects you want to add to your legend in the "entries" argument of the legend function.
Here is a simple example where I create 3 plots but only legend the 1st and 3rd. Try it out on your system!
% Create a figure window and hold on
figure
hold on;
% Create the plots
X1 = plot(1:10);
X2 = plot(10:-1:0,'r-');
X3 = plot(1:0.5:5,'g-');
% Add a legend to only X1 and X3
legend([X1 X3],'Entry1','Entry3')
Hope this helps.
- Sebastian
Catégories
En savoir plus sur Legend dans Centre d'aide et File Exchange
Produits
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!