Piecewise ColorFunction
- To: mathgroup at smc.vnet.net
- Subject: [mg125652] Piecewise ColorFunction
- From: Hugh Goyder <h.g.d.goyder at cranfield.ac.uk>
- Date: Sun, 25 Mar 2012 00:17:46 -0500 (EST)
- Delivered-to: l-mathgroup@mail-archive0.wolfram.com
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]]] ClearAll[f]; f[x_, y_] := Piecewise[{{Green, y < 0}, {Red, y >= 0}}] Plot[Sin[x], {x, 0, 4 Pi}, PlotStyle -> Thick, ColorFunction -> f]
- Follow-Ups:
- Re: Piecewise ColorFunction
- From: Bob Hanlon <hanlonr357@gmail.com>
- Re: Piecewise ColorFunction