Calling objects in legend changes marker size
조회 수: 1 (최근 30일)
이전 댓글 표시
I am using the errorbar function to plot some data, and I wish to create a legend and have access to the icons object it uses. When I use the legend function and do not call the icons object as an output, the legend plots corrently (see below).
figure
errorbar(1:5,5:-1:1,0.5:0.1:0.9,'k.','MarkerSize',100,'LineWidth',4,'CapSize',15)
legend({'Data'},'FontSize',20)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/252142/image.png)
However, when I do specify outputs of the legend function, the legend does not create an icon similar to the first example.
figure
errorbar(1:5,5:-1:1,0.5:0.1:0.9,'k.','MarkerSize',100,'LineWidth',4,'CapSize',15)
[lgd, icons, plots, txt] = legend({'Data'},'FontSize',20);
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/252143/image.png)
How can I call the legend objects whilst keeping the icon the correct size and shape?
댓글 수: 0
답변 (2개)
Dhananjay Kumar
2019년 12월 5일
This appears to be a bug.
I work at MathWorks and have forwarded this feedback to the relevant team.
댓글 수: 0
Walter Roberson
2019년 12월 5일
You will never be able to do this. When you ask for the second output of legend you invoke a backwards compatibility mode that creates legends a different way. Because the people who use this need legends to work the same way as before HG2 in R2014b, the mode has to be bug-for-bug compatible.
You will need to modify the objects that you get in the second output.
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Legend에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!