Flipping one Y axis out of two

2 ビュー (過去 30 日間)
Kushan
Kushan 2013 年 6 月 19 日
Dear All,
I have got a data set, which has one independent variable (x) and two dependent variables(y1 and y2). I want to plot the data set in one figure as given below and *finally want to flip the y axis related to y2 up side down***.
Experts please help me out
x=1:10;
y1=x.*x;
y2=5*x+3;
figure();
scatter(x,y1,50,'.','r');
hold on;
bar(x,y2,'g')
  1 件のコメント
dpb
dpb 2013 年 6 月 19 日
Use plotyy(), saving the handles. Choose the one of choice to set the y-axis direction on.

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

採用された回答

lvn
lvn 2013 年 6 月 19 日
I hope this is what you had in mind. To make sense of it, I think you need to display 2 Y-axis, the example below does that.
figure();
bar(x,y2,'g');
set(gca,'ydir','reverse');
ax1=gca;
set(ax1,'YColor','g'); axis([0 11 0 100])
ax2 = axes('Position',get(gca,'Position'), 'YAxisLocation','right', 'Color','none', 'YColor','r');
hold on;
scatter(x,y1,50,'.','r');
set(ax1,'YColor','g'); axis([0 11 0 100])

その他の回答 (1 件)

Kushan
Kushan 2013 年 6 月 19 日
Thanks :)
Its working

カテゴリ

Help Center および File ExchangeTwo y-axis についてさらに検索

製品

Community Treasure Hunt

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

Start Hunting!

Translated by