Need help with plotyy formatting

3 次查看(过去 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 个评论
Mark McNallly
Mark McNallly 2013-2-13
Hi, could you post the relevant code you're using for your problem?

请先登录,再进行评论。

采纳的回答

ChristianW
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 CenterFile Exchange 中查找有关 Two y-axis 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by