scatter plot with color dependent on variable

36 ビュー (過去 30 日間)
Dilay Durmaz
Dilay Durmaz 2022 年 6 月 11 日
コメント済み: Astthor Gislason 2022 年 9 月 1 日
How can I plot my data from the same group according to the color bar? (same group will be same colour)
  1 件のコメント
Image Analyst
Image Analyst 2022 年 6 月 12 日
If you have any more questions, then attach your data and code to read it in with the paperclip icon after you read this:

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

回答 (1 件)

Image Analyst
Image Analyst 2022 年 6 月 11 日
You can pass in a color for every data point as the fourth input argument to scatter.
Try this:
x = 1:10;
y = 51:60;
cmap = turbo(length(y))
cmap = 10×3
0.1900 0.0718 0.2322 0.2737 0.3835 0.8449 0.2093 0.6654 0.9760 0.1034 0.8960 0.7150 0.4483 0.9959 0.3694 0.7824 0.9376 0.2033 0.9800 0.7300 0.2216 0.9643 0.4186 0.0964 0.7941 0.1660 0.0143 0.4796 0.0158 0.0106
scatter(x, y, 200, cmap, 'filled')
grid on;
colormap(cmap)
colorbar
caxis([min(y), max(y)])
  4 件のコメント
Image Analyst
Image Analyst 2022 年 8 月 31 日
@Astthor Gislason that's too bad, but you didn't give us your code. I ran the code again and it gave me exactly the plot I had posted. You must have changed the code somehow.
If you have any more questions, then attach your data and code to read it in with the paperclip icon after you read this:
Astthor Gislason
Astthor Gislason 2022 年 9 月 1 日
I have solved the problem, thanks anyway.

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

カテゴリ

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

製品


リリース

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by