Mathematica , Combining 2D and 3D plots

Join the discussion
Registration is free. Ask a follow-up in this thread, or start your own.
2 replies · 14K views
PeetPb
Messages
29
Reaction score
0
Hi,

I was thinking if there is a way to combine 2D and 3D plots in mathematica. I mean, for example I have a curve on the XY plane and I want to combine it with a graph of a surface, so to have that curve under the surface. The other case , to combine a 2D vector field with a surface .. something like http://en.wikipedia.org/wiki/File:Gradient99.png"
Any Ideas ?

thanks
 
Last edited by a moderator:
Physics news on Phys.org
Hi PeetPb, welcome to PF!

The key is that you cannot Show 2D and 3D graphics together. So you have to use the 2D graphic as a Texture for a 3D polygon. Then you Show those two objects together.

Show[Plot3D[Sin[x], {x, -\[Pi], \[Pi]}, {y, -1, 1}],
Graphics3D[{Texture[Plot[Cos[x], {x, -\[Pi], \[Pi]}]],
Polygon[{{-\[Pi], -1, 0}, {\[Pi], -1, 0}, {\[Pi], 1, 0}, {-\[Pi],
1, 0}}, VertexTextureCoordinates -> {{0, 0}, {1, 0}, {1, 1}, {0,
1}}]}, Lighting -> "Neutral"]]
 
DaleSpam said:
Hi PeetPb, welcome to PF!

The key is that you cannot Show 2D and 3D graphics together. So you have to use the 2D graphic as a Texture for a 3D polygon. Then you Show those two objects together.

Show[Plot3D[Sin[x], {x, -\[Pi], \[Pi]}, {y, -1, 1}],
Graphics3D[{Texture[Plot[Cos[x], {x, -\[Pi], \[Pi]}]],
Polygon[{{-\[Pi], -1, 0}, {\[Pi], -1, 0}, {\[Pi], 1, 0}, {-\[Pi],
1, 0}}, VertexTextureCoordinates -> {{0, 0}, {1, 0}, {1, 1}, {0,
1}}]}, Lighting -> "Neutral"]]

Thanks ... for both :-) ... I really need this and I couldn't find a way to show 2d and 3d graph, and when I finally made something up the 2d graph was right in the middle of the 3d plot and had it's own axis ... anyway thank you very much it helped me very much :)

I actually found out a way how to "combine" a parametric curve and a surface

ParametricPlot3D[{{x, y, Cos[2 x + y]}, {x, x^2, -1}}, {x, 0, 2}, {y,
0, 2}, BoxRatios -> {1, 1, 1}]