Editing Legend Items for hatchfill2
25 views (last 30 days)
Show older comments
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
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:
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:
If we go up a level, we can see that we can see that this is a "LineStrip" Object
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')
which itself is composed of
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 Comments
Answers (1)
DGM
on 18 May 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 Comment
See Also
Categories
Find more on Legend in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!