Editing Legend Items for hatchfill2
26 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
I want to know more about how legends and their icons work so that I can add hatching to icons for the hatchfill2 function (link).
Here's what I know about how these icons work so far
suppose we have the following code:
A = magic(4);
plot(A)
leg = legend;
We may be able to create a simple figure with a legend
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1002735/image.jpeg)
Through some troubleshooting, I have found that we may obtain information about the legend icone as follows:
openvar('leg.EntryContainer.Children(j).Children(1).Transform.Children.Children')
where, in this case,
j = 1:4
since we are plotting
A = magic(4)
the resulting properties are visible:
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1002740/image.png)
We may verify that our understanding is correct by modifying the properties as follows:
leg.EntryContainer.Children(1).Children(1).Transform.Children.Children.LineWidth = 5;
with the following output:
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1002745/image.jpeg)
If we go up a level, we can see that we can see that this is a "LineStrip" Object
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1002750/image.png)
If we change our initial code to
A = magic(4);
area(A)
leg = legend;
we see that we have
openvar('leg.EntryContainer.Children(1).Children(1).Transform.Children')
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1002755/image.png)
which itself is composed of
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1002760/image.png)
My question is how to edit these items. Ultimately, I think the best work around I can think of is to somehow layer on multiple LineStrip objects to create the hatching, but I can't see to figure out how to layer another obejct or if this is even the best way to do this. Any input would be appreciated.
0 commentaires
Réponses (1)
DGM
le 18 Mai 2022
There are a couple examples in the answers here:
If I recall correctly, both worked when I tested them, though I don't recall whether there were any particular caveats or benefits to either.
1 commentaire
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!