Plotting multiple y axes on one side only using addaxis
Ältere Kommentare anzeigen
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
Akzeptierte Antwort
Weitere Antworten (1)
Tommy
am 1 Mai 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 Kommentare
Dirk
am 1 Mai 2020
Tommy
am 1 Mai 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
am 4 Mai 2020
Tommy
am 4 Mai 2020
You're welcome. I completely agree with Adam's advice.
Kategorien
Mehr zu Graphics Performance finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

