Is there a way to link the left and right y-axes on a GUI Axes after using yyaxis?
28 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
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 Kommentare
Adam
am 13 Jul. 2018
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.
Antworten (1)
Luis
am 18 Mär. 2019
Bearbeitet: Luis
am 18 Mär. 2019
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 Kommentare
Siehe auch
Kategorien
Mehr zu Visual Exploration finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!