散布図の重ね合わせ

조회 수: 8 (최근 30일)
Naoki Ishibashi
Naoki Ishibashi 2016년 10월 8일
댓글: Naoki Ishibashi 2016년 10월 9일
textファイルからデータを読み込み三組の散布図(TS01-TA01, TS10-TA10, TS20-TA20)を色別に重ね合わせたいのですが以下のコードですとうまく重なりません。プロット数がとても多いので確証はありませんが、グラフを見比べた限り最後のscatter(x3,y3,[],'c');しかプロットされていないようです。 アドバイスいただけると幸いです。
x1filename = ('TS20040101.txt');
y1filename = ('TA20040101.txt');
x1 = load(x1filename);
y1 = load(y1filename);
x2filename = ('TS20040110.txt');
y2filename = ('TA20040110.txt');
x2 = load(x1filename);
y2 = load(y1filename);
x3filename = ('TS20040120.txt');
y3filename = ('TA20040120.txt');
x3 = load(x1filename);
y3 = load(y1filename);
scatter(x1,y1);
hold on;
scatter(x2,y2,[],'r');
scatter(x3,y3,[],'c');
hold off;
xlabel('surface temperature');
ylabel('near-surface air temperature');
  댓글 수: 1
Image Analyst
Image Analyst 2016년 10월 8일
편집: Image Analyst 2016년 10월 8일
Approximate translation:
I read three sets of (x,y) data from six text files (TS01-TA01, TS10-TA10, TS20-TA20) and create 3 scatter plots of the data. Now I want to superimpose another color onto it, but it does not overlap well if I use the following code. Although there is no conclusive evidence the plot number is very large, the end of the scatter (x3, y3, [], 'c') as long as it was comparing the graph. It seems only not plotted. I hope I will enjoy your advice.
Please attach the 6 text data files. And attach a screenshot to show us what is not overlapping well.

댓글을 달려면 로그인하십시오.

채택된 답변

mizuki
mizuki 2016년 10월 9일
この原因は同じファイルを読み込まれているため,x1y1, x2y2, x3y3の組み合わせが変更されていないためです.
コードの7-8, 11-12行目をご覧ください.load コマンドでx1filename, y1filename を読み込まれているところを,以下のようにx2filename, y2filenameを load してみてください.
x2filename = ('TS20040110.txt');
y2filename = ('TA20040110.txt');
x2 = load(x2filename);
y2 = load(y2filename);
  댓글 수: 1
Naoki Ishibashi
Naoki Ishibashi 2016년 10월 9일
単純なコードのミスでした。ご指摘いただきありがとうございます。

댓글을 달려면 로그인하십시오.

추가 답변 (1개)

Image Analyst
Image Analyst 2016년 10월 9일
편집: Image Analyst 2016년 10월 9일
When you load x2 and y2, you're passing in the x1 and y1 filenames, not the x2 and y2 filenames like you should. Same problem for #3 - you're passing in the x1 filenames instead of the x3 filenames.
  댓글 수: 1
mizuki
mizuki 2016년 10월 9일
Thanks for translating my answer to English :)

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Startup and Shutdown에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!

Translated by