Message Boards Message Boards

0
|
4981 Views
|
2 Replies
|
2 Total Likes
View groups...
Share
Share this post:

Color ParametricPlot3D with three colors

Posted 12 years ago
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
2 Replies
Posted 12 years ago
I got it! Thank you very much.
POSTED BY: Howard Wilk
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
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract