Changing order of legend entries
조회 수: 49 (최근 30일)
이전 댓글 표시
Hi guys,
does anybody know, how to change the order of entries in the legend? Changing the order of the plots is not possible, because the black dashed lines have to be on top.![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/420508/image.png)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/420508/image.png)
Thanks!
Christian
댓글 수: 0
답변 (1개)
Ameer Hamza
2020년 11월 20일
편집: Ameer Hamza
2020년 11월 20일
You can change the order, but for that you need the handle for each line. For example, plot two lines
p1 = plot(rand(1,10));
p2 = plot(rand(1,10));
Now you can use these handles to set the order of legends
legend([p2 p1], {'P2', 'P1'})
%^ this order decide how it will appear in legend
댓글 수: 3
LIU
2022년 3월 22일
Hello, I have got similar problem. I tried what you suggest in this post, but it failed. Could you please have a look at my problem (the link is as follows ) and give some idea? Thank you very much.
참고 항목
카테고리
Help Center 및 File Exchange에서 Legend에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!