Mathematica Mathematica , Combining 2D and 3D plots

AI Thread Summary
Combining 2D and 3D plots in Mathematica requires using a 2D graphic as a texture for a 3D polygon, as direct combination is not possible. The process involves creating a 3D plot and then overlaying the 2D plot as a texture on a polygon that lies within the 3D space. An example provided demonstrates this technique using a sine function for the surface and a cosine function for the texture. Additionally, a method for combining a parametric curve with a surface is shared, showcasing the flexibility of Mathematica for visualizing complex data. This approach allows for effective integration of different graphical representations in a single visual output.
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}]
 

Similar threads

Replies
5
Views
2K
Replies
4
Views
1K
Replies
3
Views
3K
Replies
4
Views
2K
Replies
1
Views
2K
Replies
1
Views
2K
Replies
1
Views
3K
Replies
4
Views
3K
Back
Top