Editing Legend Items for hatchfill2
조회 수: 26 (최근 30일)
이전 댓글 표시
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
답변 (1개)
DGM
2022년 5월 18일
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
참고 항목
카테고리
Help Center 및 File Exchange에서 Legend에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!