Same colour for two curves in a plot

4 次查看(过去 30 天)
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
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'});

类别

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