Why does the legend of a contour plot in MATLAB 7.0 (R14) not look the way it did in MATLAB 6.5 (R13)?
5 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
If you run the code below in MATLAB 6.5 (R13) and again in MATLAB 7.0 (R14), you will see the legends in those two plots are different.
Under MATLAB 6.5, each label in 'legend' is associated with a different fill color in the contour plot. Under MATLAB 7.0, only one label is shown, and the sample face color includes all the colors in the plot.
[C,h] = contourf(peaks(20),10);
legend('A', 'B', 'C')
When I try to execute this code, I receive the following error:
Warning: Ignoring extra legend entries.
Réponse acceptée
MathWorks Support Team
le 22 Jan 2010
The way that plot legends are created in MATLAB 7.0 (R14) is different from how they were created in MATLAB 6.5 (R13).
To work around this issue, include 'v6' in the CONTOURF command. This causes the legend to be the same as it was in MATLAB 6.5.
[C,h] = contourf('v6',peaks(20),10);
legend('A', 'B', 'C')
See "Plot Objects and Backward Compatibility" in the Handle Graphics documentation for more information.
0 commentaires
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Contour Plots dans Help Center et File Exchange
Produits
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!