Need help with plotyy formatting
조회 수: 1 (최근 30일)
이전 댓글 표시
All, I am in process of trying to use plotyy to plot 4 strings of data. 2 of the strings are on the left side y axis and 2 are on the right side y axis. I was able to accomplish this by issuing the plotyy command with the first 2 strings, then issue a hold, and then another plotyy command with the final 2 strings. I have been able to format the graph entirely as desired but I am having difficulty getting the legend to appear for all 4 strings of data. When I use the set command on the property 'DisplayName' for each data string, MATLAB allows be to set this property for 3 of the 4 data strings. For the string which will not accept my input for the parameter 'DisplayName', I keep recieving an error which states:
??? Undefined function or variable 'DisplayName'.
Can someone help me with a solution to this issue so I can have a legend which shows all 4 strings? Thanks.
댓글 수: 2
채택된 답변
ChristianW
2013년 2월 13일
First legend input can be a vector of plot handles.
figure
x = 0:0.01:20;
y1 = 200*exp(-0.05*x).*sin(x);
y2 = 0.8*exp(-0.5*x).*sin(10*x);
y3 = 100*cos(x).^3;
y4 = exp(-0.5*x).*cos(x);
[AX,H1,H2] = plotyy(x,[y1;y3],x,[y2;y4],'plot'); hold on
legend([H1(1) H1(2) H2(1) H2(2)],'y1','y2','y3','y4')
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Two y-axis에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!