Changing marker color

조회 수: 24 (최근 30일)
Chad Greene
Chad Greene 2012년 3월 2일
댓글: Sahil Bharti 2021년 7월 29일
I would like to scale the color of a marker based on temperature values being plotted there. For example, to plot 10 temperatures scaled from red to white I could use
for n = 1:10
TempScaled = (Temp(n) - min(Temp))/(max(Temp)-min(Temp));
plot(x(n),y(n),'.','MarkerSize',20,'color',[TempScaled 1 1]);
end
But I would like to use a more traditional and easy-to-read color scale, such as 'hot'. Any ideas of how I can do this?
  댓글 수: 1
Sahil Bharti
Sahil Bharti 2021년 7월 29일
Hi,
I wish to use the scaller plot with data polotted with different colors as received in the ABAQUS cae output.
How to plot

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

답변 (3개)

Jan
Jan 2012년 3월 3일
color = hot(20);
for n = 1:10
TempScaled = (Temp(n) - min(Temp)) / (max(Temp) - min(Temp));
plot(x(n), y(n), '.', 'MarkerSize', 20, 'color', color(n, :));
end
[EDITED, accepted flag cleared]

Walter Roberson
Walter Roberson 2012년 3월 2일
pointsize = 20;
scatter(x, y, pointsize, TempScaled);
  댓글 수: 1
Chad Greene
Chad Greene 2012년 3월 2일
oops, I meant to "accept" this answer.

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


Chad Greene
Chad Greene 2012년 3월 2일
Both great solutions here, thanks guys! I have never used the scatter plot before, and I think that's the key. I like removing loops wherever I can. Thanks again!
  댓글 수: 1
Jan
Jan 2012년 3월 3일
There is a FOR loop inside SCATTER also. If you want to write efficient code, it would be better to replace the PLOT by LINE in your FOR loop.
It sounds like you have accepted my answer accidently. Therefore I delete it and re-post it. This remove the existing acceptance flag and you can reset it. Ok?

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

카테고리

Help CenterFile Exchange에서 Graphics Performance에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by