The Math Forum

Search All of the Math Forum:

Views expressed in these public forums are not endorsed by NCTM or The Math Forum.

Math Forum » Discussions » Inactive » comp.soft-sys.math.mathematica

Notice: We are no longer accepting new posts, but the forums will continue to be readable.

Topic: Piecewise ColorFunction
Replies: 2   Last Post: Mar 26, 2012 2:49 AM

Advanced Search

Back to Topic List Back to Topic List Jump to Tree View Jump to Tree View   Messages: [ Previous | Next ]
Goyder Dr HGD

Posts: 59
Registered: 1/29/05
Piecewise ColorFunction
Posted: Mar 25, 2012 1:19 AM
  Click to see the message monospaced in plain text Plain Text   Click to reply to this topic Reply

The first example below works to give a plot style with colours that vary with y-values. I then try to define a Piecewise function for the colour and this does not work. Am I doing something wrong? Thanks for any assistance.

Plot[Sin[x], {x, 0, 4 Pi}, PlotStyle -> Thick,
ColorFunction -> Function[{x, y}, ColorData["NeonColors"][y]]]

f[x_, y_] := Piecewise[{{Green, y < 0}, {Red, y >= 0}}]

Plot[Sin[x], {x, 0, 4 Pi}, PlotStyle -> Thick, ColorFunction -> f]

Point your RSS reader here for a feed of the latest messages in this topic.

[Privacy Policy] [Terms of Use]

© The Math Forum at NCTM 1994-2018. All Rights Reserved.