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


Groups > comp.soft-sys.math.mathematica > #9242 > unrolled thread

Re: Piecewise ColorFunction

Started byMurray Eisenberg <murray@math.umass.edu>
First post2012-03-28 05:32 +0000
Last post2012-03-28 05:32 +0000
Articles 1 — 1 participant

Back to article view | Back to comp.soft-sys.math.mathematica

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  Re: Piecewise ColorFunction Murray Eisenberg <murray@math.umass.edu> - 2012-03-28 05:32 +0000

#9242 — Re: Piecewise ColorFunction

FromMurray Eisenberg <murray@math.umass.edu>
Date2012-03-28 05:32 +0000
SubjectRe: Piecewise ColorFunction
Message-ID<jku7q8$8it$1@smc.vnet.net>
Or just simply:

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

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

On 3/26/12 2:45 AM, Bob Hanlon wrote:
>> From the documentation: "With the usual default setting
> ColorFunctionScaling ->  True, all arguments supplied to func are
> scaled to lie in the range 0 to 1."
>
> ClearAll[f];
> f[y_] = Piecewise[{{Green, y<  0}, {Red, y>= 0}}];
>
> Plot[Sin[x], {x, 0, 4 Pi},
>   PlotStyle ->  Thick,
>   ColorFunction ->  Function[{x, y}, f[y - 1/2]]]
>
> Plot[Sin[x], {x, 0, 4 Pi},
>   PlotStyle ->  Thick,
>   ColorFunction ->  Function[{x, y}, f[y]],
>   ColorFunctionScaling ->  False]
>
> ClearAll[f];
> f = Piecewise[{{Green, #2<  0}, {Red, #2>= 0}}]&;
>
> Plot[Sin[x], {x, 0, 4 Pi},
>   PlotStyle ->  Thick,
>   ColorFunction ->  f,
>   ColorFunctionScaling ->  False]
>
>
> Bob Hanlon
>
>
> On Sun, Mar 25, 2012 at 1:17 AM, Hugh Goyder
> <h.g.d.goyder@cranfield.ac.uk>  wrote:
>> 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]
>>
>

-- 
Murray Eisenberg                     murray@math.umass.edu
Mathematics & Statistics Dept.
Lederle Graduate Research Tower      phone 413 549-1020 (H)
University of Massachusetts                413 545-2859 (W)
710 North Pleasant Street            fax   413 545-1801
Amherst, MA 01003-9305

[toc] | [standalone]


Back to top | Article view | comp.soft-sys.math.mathematica


csiph-web