Group Abstract Group Abstract

Message Boards Message Boards

Color ParametricPlot3D with three colors

GROUPS:
I can color a helix with 2 colors:
ParametricPlot3D[{Sin[t], Cos[t], t/3}, {t, 0, 15},
ColorFunction -> Function[{x, y, z, t}, If[t < 5, Red, Green]],
ColorFunctionScaling -> False]



But I can't figure out how to color with 3 colors, say, t < 5 red, 5<=t<=10 green, t>10 blue.
POSTED BY: Howard Wilk
Answer
1 year ago
Instead of If[t < 5, Red, Green], it could be Piecewise[{{Red, t < 5}, {Green, 5 <= t <= 10}, {Blue, t > 10}}] .
ParametricPlot3D[{Sin[t], Cos[t], t/3}, {t, 0, 15},
ColorFunctionScaling -> False,
ColorFunction ->
  Function[{x, y, z, t},
   Piecewise[{{Red, t < 5}, {Green, 5 <= t <= 10}, {Blue, t > 10}}]]]

POSTED BY: Ilian Gachevski
Answer
1 year ago
I got it! Thank you very much.
POSTED BY: Howard Wilk
Answer
1 year ago