Changing x and y limits when using plotyy
조회 수: 5 (최근 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!