Ultimately, I handled this issue by giving up on the yy plot and did a subplot instead. I, nor a couple colleagues, was not able to get the legend to display all entries for the yyplot.
legend entries ignored after using "hold" to create plots
3 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Glenn
el 28 de En. de 2014
Respondida: Glenn
el 19 de Feb. de 2014
I created a yy plot using "hold on" because my data sets were different lengths. Since then, the legend function only recognizes 4 of the 6 data sets plotted so when I add the legend it is incomplete. Can anyone tell me how to get the other entries to show up or maybe there is a better way to plot data sets with different lengths than using the "hold" function.
Thanks!
0 comentarios
Respuesta aceptada
Más respuestas (1)
Thomas
el 28 de En. de 2014
You could concatenate multiple legend statements for the two data sets
Eg.:
x = 1900:10:1990; x=x'
y1 = 10:10:100; y1=y1'
y2 = -0.1:-0.1:-1; y2=y2'
y3 = 0.05:0.05:0.5; y3=y3'
[AX,H1,H2] = plotyy(x,y1,x,[y2,y3],'plot','plot');
legend(H1,'y1');
legend(H2,'y2','y3');
this will give you only the last legend on the plot
x = 1900:10:1990; x=x'
y1 = 10:10:100; y1=y1'
y2 = -0.1:-0.1:-1; y2=y2'
y3 = 0.05:0.05:0.5; y3=y3'
[AX,H1,H2] = plotyy(x,y1,x,[y2,y3],'plot','plot');
legend([H1;H2],'y1','y2','y3');
this will give the entire data set with legend
Ver también
Categorías
Más información sobre Legend en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!