Skip to main content
edited body
Source Link
yohbs
  • 7.1k
  • 3
  • 30
  • 61

Choose two colors:

{c1,c2}={ColorData[97, 1], ColorData[97, 2]} 

Define a custom color function:

myColorFunction[x_] := If[Cos[x] > Sin[x], c1,c2] 

Generate two plots (because you can't specify two different color functions in the same plot) and combine them:

g1 = Plot[{Sin[x], Cos[x]}, {x, 0, 2 Pi}, PlotStyle -> {c1,c2}]; g2 = Plot[Min[Sin[x], Cos[x]], {x, 0, 2 Pi}, PlotStyle -> Thickness[0.015], ColorFunctionScaling -> False, ColorFunction -> (myColorFunction[#1] &), Exclusions -> None]; Show[g2, g1, PlotRange -> {-1,1}] 

VoiláVoilà:

enter image description here

Choose two colors:

{c1,c2}={ColorData[97, 1], ColorData[97, 2]} 

Define a custom color function:

myColorFunction[x_] := If[Cos[x] > Sin[x], c1,c2] 

Generate two plots (because you can't specify two different color functions in the same plot) and combine them:

g1 = Plot[{Sin[x], Cos[x]}, {x, 0, 2 Pi}, PlotStyle -> {c1,c2}]; g2 = Plot[Min[Sin[x], Cos[x]], {x, 0, 2 Pi}, PlotStyle -> Thickness[0.015], ColorFunctionScaling -> False, ColorFunction -> (myColorFunction[#1] &), Exclusions -> None]; Show[g2, g1, PlotRange -> {-1,1}] 

Voilá:

enter image description here

Choose two colors:

{c1,c2}={ColorData[97, 1], ColorData[97, 2]} 

Define a custom color function:

myColorFunction[x_] := If[Cos[x] > Sin[x], c1,c2] 

Generate two plots (because you can't specify two different color functions in the same plot) and combine them:

g1 = Plot[{Sin[x], Cos[x]}, {x, 0, 2 Pi}, PlotStyle -> {c1,c2}]; g2 = Plot[Min[Sin[x], Cos[x]], {x, 0, 2 Pi}, PlotStyle -> Thickness[0.015], ColorFunctionScaling -> False, ColorFunction -> (myColorFunction[#1] &), Exclusions -> None]; Show[g2, g1, PlotRange -> {-1,1}] 

Voilà:

enter image description here

Source Link
yohbs
  • 7.1k
  • 3
  • 30
  • 61

Choose two colors:

{c1,c2}={ColorData[97, 1], ColorData[97, 2]} 

Define a custom color function:

myColorFunction[x_] := If[Cos[x] > Sin[x], c1,c2] 

Generate two plots (because you can't specify two different color functions in the same plot) and combine them:

g1 = Plot[{Sin[x], Cos[x]}, {x, 0, 2 Pi}, PlotStyle -> {c1,c2}]; g2 = Plot[Min[Sin[x], Cos[x]], {x, 0, 2 Pi}, PlotStyle -> Thickness[0.015], ColorFunctionScaling -> False, ColorFunction -> (myColorFunction[#1] &), Exclusions -> None]; Show[g2, g1, PlotRange -> {-1,1}] 

Voilá:

enter image description here