2016-08-03 3 views
1

텍스트 또는 범례 상자에 주석을 추가하고 싶습니다.옥타브 플롯의 추가 범례 또는 텍스트 상자 윈도우

현재 내 전설은 northeastoutside에 음모가되어 있으며 새로운 전설 (또는 텍스트 상자)을 southeastoutside 위치에 추가하고 싶습니다.

감사합니다.

+2

어디까지 시도 것을 우리에게 보여 당신의 코드는? – rayryeng

+1

"annotation"을 찾고있는 것 같아요. – Andy

답변

4

사건에 대한 자세한 정보 부족 : 내 지식을 하나의 축 개체의 자부합니다

하는 단 하나의 전설 객체를 가질 수 있습니다. 두 번째 축 객체를 사용하여 두 번째 범례를 만들 수 있습니다. 각 범례에는 각 축과 관련된 데이터 요소 만 나열됩니다. 전술 한 바와 같이 당신은 단지 2 상자에 텍스트를 원하는 경우 Matlab Newsgroup thread

a = [1:0.01:2*pi]; %create sample data 
b = sin(a); 

linehandle1 = line(a,b); %creates a line plot with handle object 
axeshandle1 = gca; % gets the handle for the axes object just created 
legendhandle1 = legend('y = sin(x)', 'location', 'northeastoutside'); %makes first legend 

axeshandle2 = axes('Position',get(axeshandle1,'Position'),'xlim',get(axeshandle1,'xlim'),'ylim',get(axeshandle1,'ylim'),'Visible','off','Color','none'); %makes invisible axes with same position and scaling 
linehandle2 = line(pi/2,1,'Color','r','Marker','o','Parent',axeshandle2); %puts data set on 2nd axes 
linehandle3 = line(pi,0,'Color','b','Marker','x','Parent',axeshandle2); 
legend_handle2 = legend('peak','zero','location','southeastoutside'); %creates legend to go with 2nd axes 

figure created with second-axes method.

에서 적응, 전설 정보 또는 데이터 레이블 반드시, 당신은 주석으로 주위를 재생할 수 있습니다. 이것은 전화하기가 더 쉽지만 원하는 위치/결과를 얻는 것이 더 어려울 수 있다는 장점이 있습니다. 원하는 모양을 얻으려면 조정할 수있는 많은 속성 옵션이 있습니다. 몇 가지 예가이 예에 나와 있습니다. legendhandle을 기반으로 크기/위치를 설정하는 더 쉬운 방법이있을 수 있습니다.

a = [1:0.01:2*pi]; %create sample data 
b = sin(a); 
plot(a,b); 
legendhandle = legend('y = sin(x)','location','northeastoutside'); 
annotation('textbox',[0.875 0.1 0.1 0.1],'string','my text','edgecolor','k','linewidth',1,'fitboxtotext','off'); 

enter image description here