Plotting multiple y axes on one side only using addaxis
Mostra commenti meno recenti
Hi,
I am using addaxis to plot multiple y axes (first pic), but is there a way to have them all appear on one side (say the right hand side). Is there a better function to do this than addaxis?

If I do this:
figure
plot(x1,y1);
addaxis(x2,y2);
set(gca,'yaxislocation','right');
I get the axes on top of each other.

Thanks
Risposta accettata
Più risposte (1)
Tommy
il 1 Mag 2020
It looks like that function flips back and forth between adding the new axes to the left and adding them to the right. How about calling the function three times and deleting the second set of axes after the third has been added?
plot(1:10, rand(10,1));
addaxis(NaN,NaN);
addaxis(1:10, rand(10,1));
axh = getaddaxisdata(gca,'axisdata');
delete(axh{1})
4 Commenti
Dirk
il 1 Mag 2020
Tommy
il 1 Mag 2020
Happy to help!
Try this:
plot(NaN,NaN);
set(gca, 'YColor', 'none');
addaxis(1:10, rand(10,1));
addaxis(NaN,NaN);
addaxis(1:10, rand(10,1));
axh = getaddaxisdata(gca,'axisdata');
delete(axh{2})
Dirk
il 4 Mag 2020
Tommy
il 4 Mag 2020
You're welcome. I completely agree with Adam's advice.
Categorie
Scopri di più su Graphics Performance in Centro assistenza e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

