필터 지우기
필터 지우기

How to change the line thickness inside the legend box ?

조회 수: 156 (최근 30일)
farzad
farzad 2020년 4월 13일
댓글: Adam Danz 2023년 1월 23일
Hi All
in the UIAxes, how do I change the line thickness inside the legend box that indicate each of the plots in the graphic interface? since if too thin, it is hard to see and the legend reading will get difficult

채택된 답변

Adam Danz
Adam Danz 2020년 4월 13일
편집: Adam Danz 2020년 4월 13일
The line properties of the legend components cannot be changes independently from the line objects they represent in the plot. So, the easiest solution is to change the line properties from within the plot.
h = plot(x,y, 'LineWidth', 1.5);
% or
h.LineWidth = 1.5;
If you want the change the legend representation without changing the line property, you can copy the line and replace its XData and YData with NaN values so it doesn't appear in the plot. Then you can change it's LineWidth property and create the legend using the new line's handle.
ax = axes();
hold on
h = plot(x,y, 'b-o');
hLeg = copyobj(h, ax);
set(hLeg, 'XData', NaN, 'YData', NaN, 'LineWidth', 1.5)
legend(hLeg)
  댓글 수: 12
Farzad Torabi
Farzad Torabi 2023년 1월 22일
Please use a new post to discuss this post to avoid unwanted comments. Many thanks!
Adam Danz
Adam Danz 2023년 1월 23일
@Farzad Torabi, you can unfollow this thread to stop getting notifications. Click the "unfollow" button under the title of your question.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Legend에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by