7
$\begingroup$

I would like to draw grids on the coordinate planes. I see that Mathematica has a built in function called facegrid but it seems to want a primitive as input. Even if I give it a blank input it used the faces of the plan input to determine which faces are which. This seems to make it impossible to draw something like I have below. How would I graph something like this below? Don't need the colors, just the lines of a grid.

enter image description here

$\endgroup$
  • 2
    $\begingroup$ You don´t need to plot anything: As an example Graphics3D[{}, FaceGrids -> All, FaceGridsStyle -> Directive[Orange, Dashed]] works just fine... $\endgroup$ – Yves Klett Dec 26 '15 at 9:20
  • $\begingroup$ Oh man...I feel dumb. Thank you. I think I'll delete this post. $\endgroup$ – Michael McCain Dec 26 '15 at 9:25
  • $\begingroup$ @YvesKlett - I updated the question... I realized I wasn't asking the question correctly. I don't believe you can use facegrid to create grids on coordinate planes that overlap like they do in the pic. Ideas? $\endgroup$ – Michael McCain Dec 26 '15 at 9:40
2
$\begingroup$
 planes = {
   {{1, 0, 0}, {0, 1, 0}},
   {{1, 0, 0}, {0, 0, 1}},
   {{0, 1/2, 1/2}, {0, 1, 0}}};

Graphics3D[InfinitePlane[{0, 0, 0}, #] & /@ planes, Axes -> True]

enter image description here

$\endgroup$
9
$\begingroup$

Just for a different flavour, you can also use Mesh on a plane.

ContourPlot3D[{x == 0, y == 0, z == 0}, {x, -1, 1}, {y, -1,1}, {z, -1, 1},
 ContourStyle -> Lighter@{Blue, Green, Red}, Mesh -> 5, MeshStyle -> Black,
 Ticks -> False, AxesLabel -> {"x", "y", "z"}, LabelStyle -> 14]

enter image description here

The Mesh->5 defines how many lines you want.

$\endgroup$
8
$\begingroup$

Here is a way to do this with graphics primitives:

grid[{v1_, v2_}, size_, color_] := {
  Lighting -> "Neutral", FaceForm[Lighter@color], EdgeForm[color], Opacity[.9],
  Polygon[{
      (v1 #[[1]] + v2 #[[2]]) + .5 (-v1 - v2),
      (v1 #[[1]] + v2 #[[2]]) + .5 (v1 - v2),
      (v1 #[[1]] + v2 #[[2]]) + .5 (v1 + v2),
      (v1 #[[1]] + v2 #[[2]]) + .5 (-v1 + v2)
      }] & /@
   Tuples[Range[-size, size, 1], {2}]
  }
Graphics3D[{
  grid[{{1, 0, 0}, {0, 1, 0}}, 10, Black],
  grid[{{1, 0, 0}, {0, 0, 1}}, 10, Darker@Green],
  grid[{{0, 1, 0}, {0, 0, 1}}, 10, Red],
  },
 ImageSize -> 1000
 ]

which produces

enter image description here

Just for fun, here is a way to reproduce your image, using textures:

chessTexture[color1_, color2_] := With[{size = 1},
  Graphics[
   {
    EdgeForm[None],
    color1,
    Rectangle[{0, 0}, {size/2, size/2}],
    Rectangle[{size/2, size/2}, {size, size}],
    color2,
    Rectangle[{size/2, 0}, {size, size/2}],
    Rectangle[{0, size/2}, {size/2, size}]
    },
   ImagePadding -> 0,
   PlotRangePadding -> None
   ]
  ]
chessboard[{v1_, v2_}, size_, color1_, color2_] := 
 With[{p = {0, 0, 0}},
  {
   EdgeForm[None], Lighting -> "Neutral",
   Texture[chessTexture[color1, color2]],
   Polygon[
    {p - size (v1 + v2), p + size v1 - size v2, p + size (v1 + v2), 
     p - size v1 + size v2},
    VertexTextureCoordinates -> {{0, 0}, {size, 0}, {size, size}, {0, 
       size}}
    ]
   }
  ]
Graphics3D[{
  chessboard[{{1, 0, 0}, {0, 0, 1}}, 10, Green, RGBColor[
   0., 0.42, 0.04]],
  chessboard[{{1, 0, 0}, {0, 1, 0}}, 10, Purple, Pink],
  chessboard[{{0, 1, 0}, {0, 0, 1}}, 10, Blue, Cyan],
  },
 ImageSize -> 1000
 ]

enter image description here

$\endgroup$
  • 1
    $\begingroup$ Very nice use of Tuples in the first solution and VertexTextureCoordinates in the second solution. $\endgroup$ – Jack LaVigne Dec 26 '15 at 19:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.