Same colour for two curves in a plot

조회 수: 4 (최근 30일)
Kenneth Bisgaard Cristensen
Kenneth Bisgaard Cristensen 2021년 4월 7일
Hi MATLAB Community,
I need to have the first and third cuve the same colour, how do i do that?
I would really ppriciate some help on how to do that.
a = [ 100, 65, 95];
b = [-100, 65, 90];
c = [50, 20, 20];
d = [-25, 20, 20];
x = linspace(-200, 100, 200)
for k = 1:numel(a)
y(k,:) = a(k)+b(k)*tanh((x+c(k))/d(k));
end
figure;
plot(x, y);

채택된 답변

DGM
DGM 2021년 4월 7일
Something like this. You'd just have to pick the colors you want.
h=plot(x,y);
set(h, {'color'}, {[1 0 0]; [1 0 1]; [1 0 0]});
  댓글 수: 1
Kenneth Bisgaard Cristensen
Kenneth Bisgaard Cristensen 2021년 4월 7일
Thanks, that worked perfectly. Exactly what I was looking for. An easy solution, I will definitely remember in the future. I appricate the help.

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

추가 답변 (1개)

Sajid Afaque
Sajid Afaque 2021년 4월 7일
you can also use color instead of triplets
h=plot(x,y);
set(h, {'color'}, {'r'; 'b'; 'r'});
  댓글 수: 2
Kenneth Bisgaard Cristensen
Kenneth Bisgaard Cristensen 2021년 4월 7일
Thanks, that is great information to have. appreciate it a lot.
Kenneth Bisgaard Cristensen
Kenneth Bisgaard Cristensen 2021년 4월 7일
Can you make it dashed as well?

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

카테고리

Help CenterFile Exchange에서 Data Distribution Plots에 대해 자세히 알아보기

태그

제품


릴리스

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by