plot filled rectangle and appear on legend
65 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
michael
le 29 Nov 2020
Commenté : Walter Roberson
le 13 Déc 2020
Hi,
I'd like to have something like that
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/433798/image.png)
I know that I can use rectangle function, but then it is not appearing on a legend.
Any suggestions how to solve the issue?
0 commentaires
Réponse acceptée
Walter Roberson
le 29 Nov 2020
Use fill() such as
fill([xmin xmax xmax xmin], [ymin ymin ymax ymax], 'facecolor', 'y')
2 commentaires
Walter Roberson
le 13 Déc 2020
Record the handle of one of the fill() calls. Pass only that handle to legend() (along with the handles of any other objects you do wish to legend() )
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Legend dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!