Plot disappears after axes command
古いコメントを表示
I have a GUI where i plot two curves in the same figure. later in the program i want to plot a third curve in the same figure. To do so i first choose that figure to plot in with the axes command. When i do so one of the previous curves disappears and i can't understand why. Someone who knows?
7 件のコメント
Adam
2016 年 7 月 26 日
Are you using hold on status?
Joakim Magnusson
2016 年 7 月 26 日
編集済み: Joakim Magnusson
2016 年 7 月 26 日
Adam
2016 年 7 月 26 日
And are you keeping hold of all handles and plotting explicitly on the correct axes rather than just relying on whatever gca is giving you? It would help if you showed some code, otherwise it is just guessing.
Brendan Hamm
2016 年 7 月 26 日
An example of actual code would be useful, but using the axes command creates an axes and does NOT tell the subsequent plot which Axes to plot on.
Joakim Magnusson
2016 年 7 月 27 日
編集済み: Joakim Magnusson
2016 年 7 月 27 日
Adam
2016 年 7 月 27 日
Are you using R2016a or later? If so the help appears to now say that plotyy is "not recommended", although it doesn't say why. It says you should use 'yyaxis' instead, which is a newer function.
Actually the axes documentation does describe one syntax which lets you provide an axes handle and it will make those axes the current axes: " axes(h) makes existing axes h the current axes and brings the figure containing it into focus"
However I would advise against using this in serious code, and instead always explicitly specify the axes in every plot function:
plotyy(axh,...)
Almost all plot functions support this, and it is ultimately much simpler and much more robust. It prevents users' clicking from changing the behavior of your code!
採用された回答
その他の回答 (0 件)
カテゴリ
ヘルプ センター および File Exchange で Two y-axis についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!