how to label second x and y axes

47 visualizaciones (últimos 30 días)
Rabih Sokhen
Rabih Sokhen el 31 de Mzo. de 2021
Comentada: Rabih Sokhen el 31 de Mzo. de 2021
hello guys
in the following code, i don't know how to label the x axis on the top and the y axis that's on the right
anybody have a idea?
thank you
clear all
clc
subplot(2,2,4)
x1 = linspace(0,100,101);
y1 = 2*x1;
x2=3*x1;
y2=4*x1;
plot(x1,y1)
xlabel('x1')
ylabel('y1')
hAx(1)=gca;
hAx(2)=axes('Position',hAx(1).Position,'XAxisLocation','top','xlim',[x2(1) x2(end)],'YAxisLocation','right','ylim',[y2(1) y2(end)],'color','none');
uistack(hAx(2), 'bottom')

Respuesta aceptada

Cris LaPierre
Cris LaPierre el 31 de Mzo. de 2021
Use the following syntax with hAx(2) as your target.
plot(1:100)
xlabel('x1')
ylabel('y1')
hAx(1)=gca;
hAx(2)=axes('Position',hAx(1).Position,'XAxisLocation','top','xlim',[0 300],'YAxisLocation','right','ylim',[0 400],'color','none');
uistack(hAx(2), 'bottom')
xlabel(hAx(2),'x2')
ylabel(hAx(2),'y2')

Más respuestas (0)

Etiquetas

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by