scatter plot with color dependent on variable

조회 수: 23 (최근 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 CenterFile Exchange에서 Scatter Plots에 대해 자세히 알아보기

제품


릴리스

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by