Azzera filtri
Azzera filtri

Need help with plotyy formatting

3 visualizzazioni (ultimi 30 giorni)
Mark Evans
Mark Evans il 13 Feb 2013
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 Commenti
Mark McNallly
Mark McNallly il 13 Feb 2013
Hi, could you post the relevant code you're using for your problem?
Azzi Abdelmalek
Azzi Abdelmalek il 13 Feb 2013
Post your code

Accedi per commentare.

Risposta accettata

ChristianW
ChristianW il 13 Feb 2013
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')

Più risposte (0)

Categorie

Scopri di più su Two y-axis in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by