フィルターのクリア

Plotyy making extra lines

2 ビュー (過去 30 日間)
Simao Nobrega
Simao Nobrega 2015 年 9 月 17 日
コメント済み: Simao Nobrega 2015 年 9 月 17 日
Hello,
I am using plotyy to plot some data. The problem is that when I plot more thant 2 sets of data in one of the y axis, it appears straight lines linking the end point of the ploted data to the origin of the axis. Here is a minimal code that produces the same result.
figure
x=0:0.1:10;
y1=-x;
y2=5*x.^2/1000;
y3=1.2*x.^2/1000;
[ax,p1,p2] = plotyy(x,y1,[x,x],[y2,y3],'plot','plot');
Any ideas on how to solve this? Thank you in advance.
Best regards,
Simão Nóbrega

採用された回答

Joseph Cheng
Joseph Cheng 2015 年 9 月 17 日
編集済み: Joseph Cheng 2015 年 9 月 17 日
Main reason is because you're concatenating the two arrays [x x] and [y2 y3] as they are 1xN each so in the code you're just plotting like
X=[x x]; %which is now 1x2N
Y23 = [y2 y3] %which is also 1x2N
figure,plot(X,Y23)
to plot more you'll have to make put then as columns.
[ax,p1,p2] = plotyy(x,y1,[x',x'],[y2',y3'],'plot','plot');
the extra line is connecting the last point [x(end),y2(end)] and [x(1), y3(1)] together.
  1 件のコメント
Simao Nobrega
Simao Nobrega 2015 年 9 月 17 日
Thank you. Problem solved and understood. Best regards

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

その他の回答 (0 件)

カテゴリ

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