# How can I plot the two functions below with same color for each value of k?

How can I plot the two functions below with same color for each value of k?

m = 10^-3;
k = {1, 5, 10, 25};
ron = 50 m;
vest[k_, M_] := k ron + ((2 + (-1 + M) M (5 + M)) ron)/(-1 + M)^2;
bb[k_, M_] := M (2 ron + k ron);
Plot[Evaluate[{vest[#, M], bb[#, M]}] & /@ k, {M, 0, 1}]

With default colors:

Block[{t = Table[{vest[k1, M], bb[k1, M]}, {k1, k}]}, Plot[t, {M, 0, 1}]]

With specified colors and styles:

Block[{t = Table[{vest[k1, M], bb[k1, M]}, {k1, k}]},
Plot[t, {M, 0, 1},
PlotStyle -> {Directive[Blue, Thick], Red, Darker@Green,
Directive[Orange, Dashed]},
PlotLegends -> (Row[{HoldForm@k,
"\[ThinSpace]=\[ThinSpace]", #}] & /@ k)]]

Evaluate the complete plot-argument:

Show[Map[Plot[ {vest[#, M], bb[#, M]},{M,0, 1},Evaluated -> True,
PlotStyle -> RGBColor[#/Max[k],0,1-#/Max[k]]] &, k], PlotRange -> All]

• this's not what I said. I want both function vest and bb have the same color for each k like vest and bb have same red for k = 1 and same blue for k = 2 and so on Nov 27, 2019 at 17:44
• Ok, see my modiefied answer. Nov 27, 2019 at 17:55
• My color above is just an example. That color is hard to distinguish, how can I change the colors? Nov 27, 2019 at 18:04
• Perhaps you find some information in the documentation of PlotStyle . Try PlotStyle -> Blend[{Red, Green, Blue}, #/Max[k]] Nov 27, 2019 at 18:32
m = 10^-3;
k = {1, 5, 10, 25};
ron = 50m;
dcr = k ron;
vest[k_, M_] := k ron + (2 + (-1 + M) M (5 + M)) ron/(-1+M)^2;
bb[k_, M_]:= (2 ron+k ron);
Plot[
Evaluate @ Flatten @ {Map[{vest[#,M],bb[#,M]}&]@k}]
,{M,0,1}
,PlotStyle-> {Green,Green,Red,Red,Blue,Blue,Orange,Orange}
]

• that looks nice but I don't think the curves with the same k don't have the same color. Also you changed the bb function! Nov 27, 2019 at 20:47

Another possibility is to use Style wrappers around the individual functions. This enables you to have both data and appearance specified in the same place:

m = 10^-3;
k = {1, 5, 10, 25};
ron = 50 m;
vest[k_, M_] := k ron + ((2 + (-1 + M) M (5 + M)) ron)/(-1 + M)^2;
bb[k_, M_] := M (2 ron + k ron);
Plot[
Evaluate[
Style[
{vest[#, M], bb[#, M]},
ColorData["Rainbow"][#/Max@k]
] & /@ k
],
{M, 0, 1}
]

Note the use of Evaluate, similar to the other answers.