Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.soft-sys.math.mathematica > #9226

Piecewise ColorFunction

From Hugh Goyder <h.g.d.goyder@cranfield.ac.uk>
Newsgroups comp.soft-sys.math.mathematica
Subject Piecewise ColorFunction
Date 2012-03-25 05:19 +0000
Organization Steven M. Christensen and Associates, Inc and MathTensor, Inc.
Message-ID <jkm9sp$bvr$1@smc.vnet.net> (permalink)

Show all headers | View raw


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]

Back to comp.soft-sys.math.mathematica | Previous | Next — Next in thread | Find similar | Unroll thread


Thread

Piecewise ColorFunction Hugh Goyder <h.g.d.goyder@cranfield.ac.uk> - 2012-03-25 05:19 +0000
  Re: Piecewise ColorFunction Helen Read <readhpr@gmail.com> - 2012-03-26 06:49 +0000
  Re: Piecewise ColorFunction David Skulsky <edskulsky@gmail.com> - 2012-03-26 06:47 +0000

csiph-web