# Legend position according to axes

조회 수: 558(최근 30일)
Timon Rayis 10 Mar 2020
댓글: Timon Rayis 10 Mar 2020
Hello I want to reposition the legend from the start of axes (not in the middle) like this
Can we do this? Here is my code
x = 1:10; y1 = 4*x; y2 = 3*x + 5; figure(1), plot(x,y1,'b',x,y2,'r')
legend('Line 1','Line 2','Location','NorthOutside','Orientation','horizontal','Box','off')

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

### 답변(1개)

Jakob B. Nielsen 10 Mar 2020
You can specify the position of your legend yourself with coordinates, rather than using a predetermined location. First two coordinates are the x and y start, second coordinates are the x-wise length and y-wise height of the legend. For example:
x = 1:10; y1 = 4*x; y2 = 3*x + 5; figure(1), plot(x,y1,'b',x,y2,'r')
legend('Line 1','Line 2','Position',[0.2 0.92 0.15 0.0869]);
legend('Orientation','horizontal')
legend('boxoff')
##### 댓글 수: 4표시숨기기 이전 댓글 수: 3
Timon Rayis 10 Mar 2020
This was exactly my doubt too. but the quick fix you suggested at the end surely helps. Thanks for that.

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

### Community Treasure Hunt

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

Start Hunting!

Translated by