MathGroup Archive 2008

[Date Index] [Thread Index] [Author Index]

Search the Archive

Just primitive ColorFunction

  • To: mathgroup at
  • Subject: [mg87348] Just primitive ColorFunction
  • From: Šerých Jakub <Serych at>
  • Date: Tue, 8 Apr 2008 05:37:53 -0400 (EDT)

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

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.


  • Prev by Date: Re: RegionPlot color
  • Next by Date: Re: need help
  • Previous by thread: Re: Filling problem in Plot3D
  • Next by thread: RE: Just primitive ColorFunction