how to label second x and y axes

39 次查看(过去 30 天)
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')

采纳的回答

Cris LaPierre
Cris LaPierre 2021-3-31
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')

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Axis Labels 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by