How do I change the color for a plot in a for loop?

조회 수: 10 (최근 30일)
Kristine
Kristine 2023년 7월 7일
댓글: Voss 2023년 7월 7일
Hi, I am trying to change the color of this dotted plot in this for loop. I want to change it to a brown color, but whenever I try hexadecimal or RGB color codes, the dots vanish. Is there a different way I should be trying this instead?

채택된 답변

Star Strider
Star Strider 2023년 7월 7일
You seem to be plotting point, not lines, in the loop, and to do that it is necessary to specify a marker.
Perhaps this —
plot(R(1), R(2), 'p', 'MarkerFaceColor',[0.3020 0.2775 0.1647], 'MarkerSize',20)
Experiment to get different results.
.
  댓글 수: 2
Kristine
Kristine 2023년 7월 7일
편집: Kristine 2023년 7월 7일
Awesome! I tried it out, and my dots have finally reappeared. Thank you for your help, Star Strider!
Star Strider
Star Strider 2023년 7월 7일
As always, my pleasure!

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

추가 답변 (1개)

Voss
Voss 2023년 7월 7일
In order for 'MarkerFaceColor' and 'MarkerSize' to have any effect, you must plot with some marker specified.
First, with no marker specified, nothing shows up:
figure
plot(2,2,'MarkerFaceColor',[0.3 0.2 0.1],'MarkerSize',20)
xlim([0 3])
ylim([0 3])
Now, with a marker specified:
figure
plot(2,2,'Marker','o','MarkerFaceColor',[0.3 0.2 0.1],'MarkerSize',20)
xlim([0 3])
ylim([0 3])
  댓글 수: 2
Kristine
Kristine 2023년 7월 7일
Thank you Voss, this worked for me. My dots have reppeared!
Voss
Voss 2023년 7월 7일
You're welcome!

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

카테고리

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

Community Treasure Hunt

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

Start Hunting!

Translated by