legend doesn't list all of the plotted lines using plotyy
조회 수: 3 (최근 30일)
이전 댓글 표시
In the code below, 8 lines are plotted, but the legend displays only 7 of them. Could somebody please explain how I can display all eight lines in the legend? Thanks very much for any suggestions
YY{1,1} = [ -0.1479019945775 -0.1207614728849 -0.0853912563830
-0.1332722959302 -0.1088113389903 -0.0769390531180
-0.1204885338805 -0.0983676376342 -0.0695513925373];
YY{2,1} = [ -0.1479019945775 -0.1207614728849 -0.0853912563830
-0.1315463790731 -0.1074015009182 -0.0759418727129
-0.1170135908441 -0.0955291160389 -0.0675440123853];
YY{1,2} = [ 1.8095706646177
1.6688286822702
1.5392601779117];
YY{2,2} = [ 1.8095706646177
1.6517555878194
1.5033917356162];
close all;
hold on;
[hPlotyy{1},plotyyAx{1,1},plotyyAx{2,1}]=plotyy([1:3],YY{1,1},[1:3],YY{1,2})
[hPlotyy{2},plotyyAx{1,2},plotyyAx{2,2}]=plotyy([1:3],YY{2,1},[1:3],YY{2,2});
legend
댓글 수: 0
채택된 답변
Cris LaPierre
2020년 10월 27일
I think the issue here is that plotyy is not designed to work with hold on. It creates 2 axes superimposed on itself. When called twice as you do, it creates 3 axes.
YY{1,1} = [ -0.1479019945775 -0.1207614728849 -0.0853912563830
-0.1332722959302 -0.1088113389903 -0.0769390531180
-0.1204885338805 -0.0983676376342 -0.0695513925373];
YY{2,1} = [ -0.1479019945775 -0.1207614728849 -0.0853912563830
-0.1315463790731 -0.1074015009182 -0.0759418727129
-0.1170135908441 -0.0955291160389 -0.0675440123853];
YY{1,2} = [ 1.8095706646177
1.6688286822702
1.5392601779117];
YY{2,2} = [ 1.8095706646177
1.6517555878194
1.5033917356162];
% Create figure using yyaxis
yyaxis left
plot([1:3],YY{1,1},[1:3],YY{2,1});
yyaxis right
plot([1:3],YY{1,2},[1:3],YY{2,2});
legend
추가 답변 (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!