Changing x and y limits when using plotyy
7 ビュー (過去 30 日間)
古いコメントを表示
I am using the guide and have a problem when trying to change the limits of the axes with two lines.
I have these sets of data: x, y1, y2
I have plotted them using the plotyy command:
[AX, h1, h2] = plotyy(x,y1,x,y2)
This occurs in one function.
A separate function controls changing the axes limits. In this example, I want to 'pan up' by adding a tenth of the variable 'ylimsd' to the y-limits.
ylims = ylim;
ylims1 = ylims(1,1);
ylims2 = ylims(1,2);
ylimsd = ylims2 - ylims1;
Problem --> if I use:
ylim(gca, ylim + (ylimsd/10))
only the line containing (x,y1) is affected, and the other line appears to be frozen and unaffected.
Is there any way I can 'pan' so that both lines move together?
P.S. I realise if I were to set the y limits immediately after the plotyy (i.e. in the same function) I could use the following code:
set(AX(1),'Ylim',ylim + (ylimsd/10))
set(AX(2),'Ylim',ylim + (ylimsd/10))
BUT I am trying to 'pan' from a separate function, so 'AX' is undefined.
0 件のコメント
採用された回答
Image Analyst
2017 年 4 月 29 日
The FAQ goes over how you can share the y axis handles or AX between different functions: http://matlab.wikia.com/wiki/FAQ#How_can_I_share_data_between_callback_functions_in_my_GUI.28s.29.3F
0 件のコメント
その他の回答 (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!