graphics - Can 2D and 3D plots be combined so that the 2D plot is the bottom surface of the 3D plot boundary?
I have a ListlinePlot function, that I would like to combine with both a Graphics3D plot and a ListPointPlot3D plot, in such a way that the ListLinePlot is the bottom of the 3D boundary cube for the 3D plots. Can this be done in Mathematica 8.0.4?
Obviously the code below fails to combine the plots in Show, but is there another way to accomplish this? Thanks!
Needs["TetGenLink`"]
twodPts = RandomReal[{-1, 1}, {10, 2}];
threedPts = RandomReal[{-1, 1}, {50, 3}];
{pts, surface} = TetGenConvexHull[threedPts];
twoDptsPlot = ListLinePlot[twodPts, ImageSize -> {200, 200}];
threeDPtsPlot = ListPointPlot3D[threedPts, ImageSize -> {200, 200}];
surfacePlot =
Graphics3D[{EdgeForm[], Opacity[0.3],
GraphicsComplex[pts, Polygon[surface]], ImageSize -> {200, 200}}];
{twoDptsPlot,
Show[threeDPtsPlot, surfacePlot, ImageSize -> {200, 200},
BoxRatios -> 1, Axes -> False]}

Answer
The following is probably what you want.
Make3d[plot_, height_, opacity_] :=
Module[{newplot},
newplot = First@Graphics[plot];
newplot = N@newplot /. {x_?AtomQ, y_?AtomQ} :> {x, y, height};
newplot /. GraphicsComplex[xx__] :> {Opacity[opacity], GraphicsComplex[xx]}
]
Show[{Graphics3D[Make3d[twoDptsPlot, -1, .75]], threeDPtsPlot,surfacePlot}, Axes -> True]
which gives 
This function can takes any 2D plot and place it on a 3D box with a specified height. I got this trick in the web few years back but now cant remember the reference. Hope this helps you.
Comments
Post a Comment