5
votes

How do I plot for example a plane and a line in same 3D plot?

3

3 Answers

8
votes

Show and Plot3D can handle it. There are probably many other ways.

l = Line[{{-2, -2, 41}, {6, 4, -10}}];

Show[{Plot3D[{2 x + 7 y}, {x, -2, 5}, {y, -2, 5},  AxesLabel -> {x, y, z}], 
      Graphics3D[{Thick, l}]}]

Plot3D

8
votes

Just showing off: enter image description here

Manipulate[

 Show[
  {Plot3D[ {1}, {x, -1, 1}, {y, -1, 1}, PlotRange -> {-1, 1}, Mesh -> False],
   Plot3D[{-1}, {x, -1, 1}, {y, -1, 1},                       Mesh -> False],
   ParametricPlot3D[{{Sin@t, Cos@t, 1}, {Sin@t, Cos@t, -1}}, {t, 0, 2 Pi}],
   Graphics3D[
    {Table[{Hue[n/10], Thick, Line[{{Re[#], Im[#], 1}, {-z Re[#], -z Im[#], z}}&@
         Exp[n 2 I Pi/10]]}, {n, 10}],
     Sphere[{0, 0, 0}, .3]}]}],
    {z, 1, -1}]
7
votes

I couldn't resist either...

enter image description here

GraphicsGrid[
 {
  {ContourPlot3D[x + 2 y + 3 z , {x, -2, 2}, {y, -2, 2}, {z, -2, 2}, 
    Contours -> {0}, Axes -> None, ColorFunction -> (White &), 
    Lighting -> "Neutral"], 
   Style["One plane", FontFamily -> "Comic Sans MS", 36, Bold]},
  {ContourPlot3D[x + 2 y + 3 z , {x, -2, 2}, {y, -2, 2}, {z, -2, 2}, 
    Contours -> {0, 5}, Axes -> None, ColorFunction -> (Green &), 
    Lighting -> "Neutral"], 
   Style["Two plane", FontFamily -> "Comic Sans MS", 36, Bold]},
  {ContourPlot3D[x + 2 y + 3 z , {x, -2, 2}, {y, -2, 2}, {z, -2, 2}, 
    Contours -> {0}, Axes -> None, ColorFunction -> (Red &), 
    Lighting -> "Neutral"], 
   Style["Red plane", FontFamily -> "Comic Sans MS", 36, Bold]},
  {Show[
    ContourPlot3D[x + 2 y + 3 z , {x, -2, 2}, {y, -2, 2}, {z, -2, 2}, 
     Contours -> {0}, Axes -> None, ColorFunction -> (Blue &), 
     Lighting -> "Neutral"],
    Graphics3D[{Orange, Thickness[0.01], 
      Line[{{-2, -2, -2}, {2, 2, 2}}]}]
    ], Style["Blue plane", FontFamily -> "Comic Sans MS", 36, Bold]}
  }
 ]