scatter plot with color dependent on variable
古いコメントを表示
How can I plot my data from the same group according to the color bar? (same group will be same colour)
1 件のコメント
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 件)
Try this:
x = 1:10;
y = 51:60;
cmap = turbo(length(y))
scatter(x, y, 200, cmap, 'filled')
grid on;
colormap(cmap)
colorbar
caxis([min(y), max(y)])
4 件のコメント
Image Analyst
2022 年 6 月 12 日
You're going to have to get the angle of each data point because it seems like you want the color to depend on what angle it's at rather than what the y value iso get an index into the colormap for that data point. That's because it seems like the color depends on the angle away from the diagonal.
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
2022 年 8 月 31 日
I ran the code and it does not work for me. I get the error:
Error using scatter
Index in position 2 exceeds array bounds. Index must not exceed 1.
I
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
2022 年 9 月 1 日
I have solved the problem, thanks anyway.
カテゴリ
ヘルプ センター および File Exchange で Scatter Plots についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
