The output of the Mathematica command
ListPointPlot3D[
Join @@ Table[{x, y, 0}, {x, -6, 6, 1}, {y, -6, 6, 1}],
PlotStyle -> PointSize[0.02]]
is the following image.
I want to color the points (0,0) and (1,2) with the color red. How do I modify the above command for this?
One could use the ColorFunction
option to ListPointPlot3D
:
color[0, 0, _] = Red;
color[1, 2, _] = Red;
color[_, _, _] = Blue;
ListPointPlot3D[
Join @@ Table[{x, y, 0}, {x, -6, 6, 1}, {y, -6, 6, 1}],
PlotStyle -> PointSize[0.02],
ColorFunction -> color, ColorFunctionScaling -> False]
It is important to include the ColorFunctionScaling -> False
option because otherwise the x, y and z co-ordinates passed to the colour function will be normalized into the range 0 to 1.
ColorFunction
also allows us to define point colouring using arbitrary computations, for example:
color2[x_, y_, _] /; x^2 + y^2 <= 9 = Red;
color2[x_, y_, _] /; Abs[x] == Abs[y] = Green;
color2[_, _, _] = Blue;
ListPointPlot3D[
Join @@ Table[{x, y, 0}, {x, -6, 6, 1}, {y, -6, 6, 1}],
PlotStyle -> PointSize[0.02],
ColorFunction -> color2, ColorFunctionScaling -> False]
A very simple and straightforward way would be:
list = Join @@ Table[{x, y, 0}, {x, -6, 6, 1}, {y, -6, 6, 1}];
pts = {{0, 0, 0}, {1, 2, 0}};
ListPointPlot3D[{Complement[list, pts], pts},
PlotStyle -> PointSize[0.02]]
Of course, I left it without explicitly specifying colors because the next default color is red. However, if you want to specify your own, you can modify it a little more as:
ListPointPlot3D[{Complement[list, pts], pts},
PlotStyle -> {{Green, #}, {Blue, #}} &@PointSize[0.02]]
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With