I am plotting a function z=f(x,y) using Plot3D.
Plot3D[x^2 + y^2 - 100, {x, 1, 10}, {y, 1, 10}]
How can I have different colors for positive and negative values of z? Many thanks in advance.
Sincerely,
Cuneyt
I am plotting a function z=f(x,y) using Plot3D.
Plot3D[x^2 + y^2 - 100, {x, 1, 10}, {y, 1, 10}]
How can I have different colors for positive and negative values of z? Many thanks in advance.
Sincerely,
Cuneyt
Plot3D[x^2 + y^2 - 100, {x, 1, 10}, {y, 1, 10}, ColorFunction → Function[{x, y, z}, Hue[z]]]
But I have no idea why this doesn’t work (at least on my system: Mma 7.0)
Plot3D[x^2 + y^2 - 100, {x, 1, 10}, {y, 1, 10}, ColorFunction -> Function[{x, y, z}, If[z > 0, Hue[.02], Hue[.5]]]]
Does somebody know?
Hans,
You always need to use ColorFunctionScaling->False if you want to use absolute number values from the function.
This works:
Plot3D[x^2 + y^2 - 100, {x, 1, 10}, {y, 1, 10},
ColorFunction -> Function[{x, y, z}, If[z > 0, Hue[0.2], Hue[0.5]]],
ColorFunctionScaling -> False]
or
Plot3D[x^2 + y^2 - 100, {x, 1, 10}, {y, 1, 10},
ColorFunction -> Function[{x, y, z}, If[z > 0, Red, Blue]],
ColorFunctionScaling -> False]
Regards,
Neil
Hans and Neil,
Thank you both for your responses. I have one more quick question. The boundary between the two colors is blurry. Is there a way to fix that?
Sincerely,
Cuneyt
@ Neil: thanks a lot. I didn’t know that, and I think it is not written very clearly in the “Help” ( Version 7.0 ). So I overlooked that.
@Cuneyt
Is this better?
Plot3D[x^2 + y^2 - 100, {x, 1, 10}, {y, 1, 10},
ColorFunction -> Function[{x, y, z}, If[z > 0, Red, Blue]],
ColorFunctionScaling -> False, PlotPoints -> 100]
Much better! Thanks, Neil!