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!