Mathematica , Combining 2D and 3D plots

Click For Summary
SUMMARY

This discussion focuses on combining 2D and 3D plots in Mathematica. Users cannot directly display 2D and 3D graphics together; instead, the 2D graphic must be used as a texture for a 3D polygon. The provided code example demonstrates how to achieve this by using the Show function with Plot3D and Graphics3D. Additionally, a method for combining a parametric curve with a surface using ParametricPlot3D is shared, illustrating the versatility of Mathematica for complex visualizations.

PREREQUISITES
  • Familiarity with Mathematica syntax and functions
  • Understanding of 2D and 3D plotting concepts
  • Knowledge of texture mapping in 3D graphics
  • Experience with parametric equations and their graphical representation
NEXT STEPS
  • Explore the Show function in Mathematica for combining graphics
  • Learn about texture mapping using Texture in 3D plots
  • Investigate advanced plotting techniques with ParametricPlot3D
  • Review the documentation on Graphics3D for enhanced 3D visualizations
USEFUL FOR

Mathematica users, data visualizers, educators, and researchers looking to enhance their graphical presentations by integrating 2D and 3D plots effectively.

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 ·
Replies
5
Views
2K
  • · Replies 5 ·
Replies
5
Views
3K
  • · Replies 9 ·
Replies
9
Views
3K
  • · Replies 4 ·
Replies
4
Views
2K
  • · Replies 4 ·
Replies
4
Views
3K
  • · Replies 3 ·
Replies
3
Views
3K
  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 1 ·
Replies
1
Views
3K
  • · Replies 6 ·
Replies
6
Views
2K