how to label second x and y axes

47 ビュー (過去 30 日間)
Rabih Sokhen
Rabih Sokhen 2021 年 3 月 31 日
コメント済み: Rabih Sokhen 2021 年 3 月 31 日
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')
  1 件のコメント
Rabih Sokhen
Rabih Sokhen 2021 年 3 月 31 日
thanks you

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeAxis Labels についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by