Is there a way to link the left and right y-axes on a GUI Axes after using yyaxis?
조회 수: 37 (최근 30일)
이전 댓글 표시
I haven't been able to find any documentation on it and linkaxes() specifies 'axes' in particular rather than a particular axis attached to an axes. I have plotted the data that I have on each y-axis, but when I use 'zoom', it only zooms on one of the two y-axes. Example code below is from the Matlab documentation for yyaxis:
x = linspace(0,10);
y = sin(3*x);
yyaxis left
plot(x,y)
z = sin(3*x).*exp(0.5*x);
yyaxis right
plot(x,z)
ylim([-150 150])
% linkaxes((yyaxis left)? (yyaxis right)?)
I'm not able to save each yy-axis to a variable so I can't reference it that way either. Any help with this is greatly appreciated!
댓글 수: 4
Adam
2018년 7월 13일
You'd probably be better off explicitly using two axes in the same location and putting the axis of one on the right. The whole yyaxis thing seems very underwhelming to me whenever I've used it in terms of functionality it allows. I don't really know why it was programmed the way it was, but it isn't user friendly, not consistent with being able to work with explicit axes handles for plotting-related instructions.
답변 (1개)
Luis
2019년 3월 18일
편집: Luis
2019년 3월 18일
There is a function similar to 'linkaxes' call 'linkprop' that do the trick. You only need to link the 'Limits' property on each YAxis. Here an example code:
% Create some plot
x=0:100;
plot(x,sin(.1*x).^2*1000);
grid on
% Add a second axis
yyaxis right
ax=gca();
ax.YAxis(2).TickValues = [10 100 1000];
ax.YTickLabel = {'10^1','10^2','10^3'};
%% Link the 'Limits' property
r1=ax.YAxis(1);
r2=ax.YAxis(2);
linkprop([r1 r2],'Limits')
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Visual Exploration에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!