Plotting multiple y axes on one side only using addaxis
Mostrar comentarios más antiguos
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
Respuesta aceptada
Más respuestas (1)
Tommy
el 1 de Mayo de 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 comentarios
Dirk
el 1 de Mayo de 2020
Tommy
el 1 de Mayo de 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
el 4 de Mayo de 2020
Tommy
el 4 de Mayo de 2020
You're welcome. I completely agree with Adam's advice.
Categorías
Más información sobre Graphics Performance en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

