scatter with custom color of point

1 回表示 (過去 30 日間)
Gaetano Pavone
Gaetano Pavone 2019 年 12 月 8 日
コメント済み: Star Strider 2019 年 12 月 8 日
I have a timetabel TT with 3 columns and 153424 rows:
column 1 named Timewh1
column 2 named Var1_TTwh1hourclean
column 3 named Var1_TTERA5swh;
I would like to scatter plot 2nd and 3rd columns with a custom color of points. In particular, since such points are related to the comparison between observed and modelled data, I want that the color of point, in a colorbar from 0 to 1, is equal to 1 if observed data is equal to modelled data.
I try to build the vector of the ratios:
color=TT.Var1_TTERA5swh./TT.Var1_TTwh1hourclean;
and plot this scatter:
scatter(TT.Var1_TTwh1hourclean,TT.Var1_TTERA5swh,[],color);
but the result is not equal to the desired one:
Moreover, I would like to add a dashed line as a bisector of the plot. How can I do this?
Cattura.JPG

回答 (1 件)

Star Strider
Star Strider 2019 年 12 月 8 日
I am not certain what you want.
Try this:
x = rand(1, 20);
y = rand(1, 20);
c = y >= 0.5; % Determines Colour
figure
scatter(x, y, [], c, 'o')
hold on
plot(xlim, [1 1]/2, '--k')
hold off
xlabel('x')
ylabel('y')
colormap([1 0 0; 0 1 0])
colorbar
Experiment to get different results.
This example produced this plot:
scatter with custom color of point - 2019 12 08.png
  2 件のコメント
Gaetano Pavone
Gaetano Pavone 2019 年 12 月 8 日
I want a picture like this:
Cattura.JPG
Star Strider
Star Strider 2019 年 12 月 8 日
I cannot guess what your data are, or how you want to categorise them. My code does what you initially requested.
To get a diagonal dashed line:
plot(xlim, ylim, '--k')
Without more details, I can go no further.

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

カテゴリ

Help Center および File ExchangeScatter Plots についてさらに検索

タグ

製品


リリース

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by