# Combining gradient color schemes on a ContourPlot [duplicate]

## Starting point

Function of interest: $$f(x,y)=-\frac{2 x^5+x y+2 y^7}{x^2+y^2}$$

f[x_, y_] = -((2 x^5 + x y + 2 y^7)/(x^2 + y^2))

ContourPlot:

ContourPlot[(x (-2 x^4 + y) + y (-2 x - 2 y^6))/(x^2 + y^2), {x, -2, 2}, {y, -2, 2}]


The purpose of the plot is to distinguish regions where $f(x,y) > 0$ from regions where $f(x,y) < 0$ using two different colors. Perhaps blue for positive, red for negative. The brightness can be a scale. Very blue is very positive. Near $0$, both colors are extremely faint.

Question: How can we write a ColorFunction for ContourPlot which allows a combination of two monochromatic brightness gradients?

The ultimate goal is to produce as aesthetically pleasing chart that quickly lets the user sort positive from negative regions. Unleash your inner aesthete if you have a grander scheme

Didn't see how to get there starting here How can I combine two color schemes for plotting?
@David G. Stork has a great idea, shown below. A dab of polish is needed to get the red colors to appear in negative land and to make the higher values darker, not lighter. (Contour labels added for debugging.)

• What color do you want at zero? – David G. Stork May 12 '17 at 21:31
• @David G. Stork: At the risk of being a Philistine, my first thought was to have a very light shading. Red if negative, blue if positive. The final plot will include a thick line for the contour of 0 value which will provide a strong demarcation. Better ideas are always welcome. – dantopa May 12 '17 at 21:45

ContourPlot[(x (-2 x^4 + y) + y (-2 x - 2 y^6))/(x^2 + y^2), {x, -2,
2}, {y, -2, 2},
ColorFunction -> (If[#1 > 0, Blend[{Blue, White}, #1],
Blend[{Red, White}, Abs[#1]]] &),
Mesh -> 1,
MeshFunctions -> (#3 &),
MeshStyle -> {Thick, Green}]


with a thick green line at $z = 0$.

Personally, I prefer this plot:

Plot3D[(x (-2 x^4 + y) + y (-2 x - 2 y^6))/(x^2 + y^2),
{x, -2, 2}, {y, -2, 2},
ColorFunction -> (If[#1 > 0, Blend[{Blue, White}, #1],
Blend[{Red, White}, Abs[#1]]] &),
MeshFunctions -> (#3 &),
Mesh -> 1,
MeshStyle -> {Thickness[0.02], Green}]