RE: Just primitive ColorFunction

• To: mathgroup at smc.vnet.net
• Subject: [mg87383] RE: [mg87348] Just primitive ColorFunction
• From: "Jose Luis Gomez" <jose.luis.gomez at itesm.mx>
• Date: Wed, 9 Apr 2008 05:54:45 -0400 (EDT)
• References: <200804080937.FAA12080@smc.vnet.net>

```Dear Serych

It is Not necessary to use ColorFunction. You can achieve this goal with
FillingStyle->{Red,Blue}, try the following code:

Plot[Sin[x],{x,0,4 Pi},
AxesOrigin->{0,0},
Axes->{True,True},
PlotStyle->Thick,
FillingStyle->{Red,Blue},
Filling->Axis,
ImageSize->{380,280}]

Saludos!
Jose
Mexico

-----Mensaje original-----
De: =A9er=FDch Jakub [mailto:Serych at panska.cz]
Enviado el: Martes, 08 de Abril de 2008 04:38 a.m.
Para: mathgroup at smc.vnet.net
Asunto: [mg87348] Just primitive ColorFunction

I think, that it must be something very simple, but I cannot find the
solution....

I need to fill the Plot so, that area above the axis will be red and =
area
below the axis will be blue. I tried it in a such way:

Plot[Sin[x], {x, 0, 4 Pi} ,
AxesOrigin -> {0, 0},
Axes -> {True, True},
PlotStyle -> Thick,
ColorFunction ->
If[Sin[x] >= 0, RGBColor[1, 0, 0], RGBColor[0, 0, 1]],
Filling -> Axis,
ImageSize -> {380, 280}]

But Mathematica says, that If is not a valid Color.

If I try it with Function (according to examples in ColorFunction help),

ColorFunction ->
Function[x, If[Sin[x] >= 0, RGBColor[1, 0, 0], RGBColor[0, 0, 1]]],

it is working, but the color of Filling is red allover the range.

Thanks for any hint, how to achieve the +Red/-Blue filling.

Jakub

```

• Prev by Date: Re: Problems with recursive function
• Next by Date: Re: Problems with recursive function
• Previous by thread: Just primitive ColorFunction
• Next by thread: Re: Just primitive ColorFunction