plotyy with non-coincident x data sets, do not want two separate x axes

1 回表示 (過去 30 日間)
Jenny
Jenny 2015 年 9 月 11 日
コメント済み: Star Strider 2015 年 9 月 12 日
I am using plotyy to plot one normal y axis, the other y axis as a semilogy. The x values on one data set go from 8 - 24, the other data set 8.5 - 35. I want the two data sets to be on a single x axis that goes from 8 - 35 as they are coincident measurements in time (hours). Is there a way to do this?

回答 (1 件)

Star Strider
Star Strider 2015 年 9 月 11 日
It should do that by default:
x1 = linspace(8, 24, 10);
x2 = linspace(8.5, 35, 10);
y = randi(99, 2, 10);
figure(1)
plotyy(x1,y(1,:), x2,y(2,:), 'plot', 'semilogy')
set(gca, 'XLim', [8 35])
The set call is simply to limit the axes to your specifications. Otherwise it will plot them from 5 to 35.
  2 件のコメント
Jenny
Jenny 2015 年 9 月 12 日
Thanks very much. Problem fixed!
Star Strider
Star Strider 2015 年 9 月 12 日
My pleasure!
I would of course appreciate for you to Accept my Answer if it solved your problem.

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

カテゴリ

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