필터 지우기
필터 지우기

How can I resize the horizontal lineLength in Legend?

조회 수: 3 (최근 30일)
andrea
andrea 2014년 10월 18일
답변: Chris Turnes 2014년 10월 18일
For ex.:
plot(x,sin(x));
[r, hobj1]=legend('sin(x)');
textobj = findobj(hobj1, 'type', 'line');
set(textobj,'???????????', 8); %Is there any lineProperty like 'lineLength'?
Thanks in advance!

답변 (1개)

Chris Turnes
Chris Turnes 2014년 10월 18일
When I try this in R2014a, two objects are returned into textobj, and the first seems to correspond to the line that is drawn in the legend. I can then access and change the length of the line with the following commands:
>> lineXData = get(textobj(1), 'XData');
>> lineXData(2) = 0.6; % Change this line to give you the x coordinates you want
>> set(textobj(1), 'XData', lineXData);
The units for the legend are normalized, so you may have to figure out the unit conversion, but this should do the trick.

카테고리

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