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 ビュー (過去 30 日間)
古いコメントを表示
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 件のコメント
採用された回答
その他の回答 (1 件)
Thomas
2014 年 1 月 28 日
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
参考
カテゴリ
Help Center および File Exchange で Legend についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!