Plotting a continuous function in discontinuously

I have a function called $s$ which is a very complicated function of two variables x and y. I want to plot a 2d graph with axes representing x and y parameters and colored points show sign of function $s$ for $x=x_0$ and $y=y_0$ (For example if $s(x_0,y_0)$ is positive it plots a blue point and if not, it plots red point in $(x_0,y_0)$ position of the graph.)

I want $x_0$ to go from $x_1$ to $x_2$ with step equal to $\Delta x$ and $y_0$ to go from $y_1$ to $y_2$ with step equal to $\Delta y$. The reason I want to do that is: Plot3D cannot plot $s(x,y)$, because as I mentioned, it is a very difficult function of x and y. The code I used to plot the function is as below but I don't know how to plot different colors for different signs(nagative and positive):

ListPointPlot3D[Table[s, {x, 0.03, 1, 0.05}, {y, 40, 50, 1}]]

Any answers with an example will be highly appreciated.

• ColorFunction will let you use ListPointPlot to plot only red or blue points. ListPointPlot3D[Table[{x, y, Sin[x] Cos[y]}, {x,-Pi,Pi,Pi/16}, {y,-Pi,Pi,Pi/16}], ColorFunction->Function[{x,y,z}, If[z<1/2, Red, Blue]]] but MMA has already chosen a scaled color value by the time it gets to ColorFunction and you can't just say "I want negative z values printed in blue", not unless you want to just use Graphics and you have already said several times you don't want to do that. Perhaps you can try this on your function, adjust the 1/2 if needed and see if it works. Watch out for Complex values though – Bill Dec 16 '16 at 16:18

Let's say your complicated function is Sin[x]Sin[y]

data = Flatten[Table[{x, y, Sin[x] Sin[y]}, {x, 0, 2 Pi, 0.1}, {y, 0, 2 Pi, 0.1}], 1];

ListDensityPlot[data, PlotLegends -> True] or point by point with your choice of color

Graphics[{If[#[] >= 0, Blue, Red], Point[#[[1 ;; 2]]]} & /@ data, Frame -> True] • Graphics doesn't work in my case. Is there any way that I could use listpointplot? – sara nj Dec 16 '16 at 13:49
• @saranj Please be specific as to why it doesn't work. Do you get specific errors or is there something about your data that can't work with Graphics? – JimB Dec 16 '16 at 15:21

It sounds like you might want DiscretePlot3D:

DiscretePlot3D[
Sin[8 x] + Cos[x + y],
{x, 0.03, 1, 0.05}, {y, 40, 50, 1},
ColorFunction -> Function[{x, y, z}, If[z > 0, Blue, Red]],
ColorFunctionScaling -> False,
Filling -> None
] Of course, it's basically the same as ListPointPlot3D, with different styling, plus you can reuse the data:

data = Table[{x, y, Sin[8 x] + Cos[x + y]}, {x, 0.03, 1, 0.05}, {y, 40, 50, 1}];
ListPointPlot3D[data,
ColorFunction -> Function[{x, y, z}, If[z > 0, Blue, Red]],
ColorFunctionScaling -> False]
] FWIW, you can get the same computation restrictions on Plot3D, ContourPlot, etc. by choosing PlotPoints and setting MaxRecursion -> 0. Be advised that Plot3D will tweak the plot points off a regular grid slightly.

Plot3D[Sin[8 x] + Cos[x + y], {x, 0.03, 1}, {y, 40, 50},
PlotPoints -> pp, MaxRecursion -> 0, MeshFunctions -> {#3 &},
Mesh -> {{0}}, MeshShading -> {Red, Blue}] 