# Discrete ContourPlot3D with restrictions

I have the follow simple condition between integers: k - 2 h - l == 0, which describe a plane that I plot with:

ContourPlot3D[x - 2*y - z == 0, {x, -2, 2}, {y, -2, 2}, {z, -2, 2}]


Now the problem I have is: How can I plot the same plane under these restrictions:

• plot only discrete numbers (x = 1, 2, 3, ...; y = 1, 2, 3, ...; z = 1, 2, 3, ...);
• Mathematica should observe rules on the integers (e.g.: plot only the positive integers for which k ≠ h)

If you want to separately see the plane, the grid of integer point positions, and those points that meet your criteria, you might want to try something like this:

With[{max=2,plane={x,y,z}\[Function]x-2y-z==0},
Module[{zz,grid,filter},
zz=z/.Solve[plane[x,y,z],z];
grid=Select[Tuples[Range[-max,max],3],p\[Function]plane@@p];
filter[{k_,h_,l_}]:=(k>=0)&&(h>=0)&&(l>=0)&&(k!=h);
Show[{
ParametricPlot3D[{x,y,zz},{x,-max,max},{y,-max,max},Mesh->None,PlotStyle->Directive[Opacity[0.5],Gray]],
Graphics3D[{
{Gray,Opacity[0.5],Sphere[#,0.19]&/@grid},
{Red,Sphere[#,0.2]&/@Select[grid,filter]}
}]
},BoxRatios->{1,1,1},PlotRange->max+0.5,Lighting->"Neutral"]
]
]


You might want to set max to a larger value to see how the set of selected points looks.

Is this the sort of thing you mean?

rgnFn[{x_, y_, z_}] := x - 2*y - z == 0;
Graphics3D[
Translate[Cuboid[], Select[Tuples[Range[-2, 2], 3], rgnFn] - 1/2],
Axes -> True, AxesLabel -> {x, y, z}]


Select here is used to pick the coordinates to be plotted. Subtracting 1/2 above centers the cube on the coordinate.

Select[Tuples[Range[-2, 2], 3], rgnFn]
(*
{{-2, -2,  2}, {-2, -1,  0}, {-2,  0, -2}, {-1, -1,  1}, {-1,  0, -1},
{ 0, -1,  2}, { 0,  0,  0}, { 0,  1, -2}, { 1,  0,  1}, { 1,  1, -1},
{ 2,  0,  2}, { 2,  1,  0}, { 2,  2, -2}}
*)

• @micheal thanks a lot, this can fit the answer of the first question pretty good. Thanks again. Commented Jun 10, 2014 at 13:49
• @PanichiPattumerosPapaCastoro If you also want to constrain x != y, then change the region function to rgnFn[{x_, y_, z_}] := x - 2*y - z == 0 && x != y. Commented Jun 10, 2014 at 15:03
• @PanichiPattumerosPapaCastoro Please, take a tour.
– Kuba
Commented Jun 10, 2014 at 15:04