How can I change the appearance of the lines in the legend in a MATLAB figure?
조회 수: 6 (최근 30일)
이전 댓글 표시
I want to alter the appearance of the lines in the legend in my MATLAB figure. For example, the markers are too small and difficult to see. I would like to make them larger.
채택된 답변
MathWorks Support Team
2010년 8월 31일
The handles for the line objects in the legend are returned as part of the output from LEGEND. You can use the SET command to change the properties if you have the lines' handles:
x = 1:10;
y1 = rand(1,10); % 10 random numbers
y2 = randn(1,10); % 10 normally distributed random numbers
plot(x,y1,'rx--',x,y2,'bo-')
[legh,objh] = legend('curve1','curve2'); % handles to the legend and its objects
There would be two line objects each (4 in total) associated to each of the line objects in the original plot.This can be found by:
% find the handles in 'objh' that correspond to line objects
lineh = findobj(objh,'type','line')
Two are used to display the lines' LineStyle with their Marker property set to 'none'. The other two are used to display the same markers as the lines in the plot with their linestyles set to 'none'. Setting the MarkerSize will only affect the appearance of the lines that have markers.
% set the marker size
set(lineh,'MarkerSize',10)
댓글 수: 0
추가 답변 (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!