Mathematica Mathematica 3D plotting question

Click For Summary
A user seeks assistance in creating a 3D graph that combines a scatter plot and a plane, with data ideally imported from an Excel file. They provide a method to generate random data and save it as a CSV file, which can then be imported into Mathematica using the Get function. The user successfully creates a plane using Graphics3D and combines it with the scatter plot using Show. They also express a desire to add opacity to the plane in their Plot3D function and initially struggle to find the correct syntax but later discover that using PlotStyle with Directive can achieve the desired opacity effect.
Wesleytf
Messages
31
Reaction score
0
I'd like to make a single 3D graph that contains a scatter plot and a plane. Ideally I'd like to import the data for the point from an excel file, but if I have to punch it in, I can find a few hours to kill. Anyway, can anyone help me with the code for this? I can get a 3D scatter plot where I'm just typing in the coordinates of each point, but I'm not sure where to go from there.
 
Physics news on Phys.org
To emulate getting some data from excel, here's some random data - saved as a csv file:

In[1]:= data=RandomReal[{0,1},{50,3}];
In[2]:= Save[ToFileName[NotebookDirectory[], "data.csv"],data]

All you need to do is save your table of data as a csv file from excel. Probably using save as or maybe export. The load it into mma using, eg

In[3]:= Get[ToFileName[NotebookDirectory[], "data.csv"]];

Here's a plane...

In[4]:= plane=Graphics3D[{Opacity[.5],Polygon[{{0,0,.4},{0,1,.4},{1,1,.4},{1,0,.4}}]}];

Here's a scatter plot + plane:

In[5]:= Show[ListPointPlot3D[data, PlotStyle->Red], plane]
 
Thanks for the help-- I wound up using this for the plane:

plane = Plot3D[{1.295*x + .6415*y + 16.09}, {x, -3, 3}, {y, -3, 3} ]

I'd like to make add in Opacity[.5], but I'm not sure where to put it in and the Plot3D help file doesn't show it as an option (at least that I can find). Any advice?
 
Nevermind, I found it!

PlotStyle -> Directive[Opacity[0.5]]
 

Similar threads

  • · Replies 4 ·
Replies
4
Views
2K
  • · Replies 5 ·
Replies
5
Views
2K
  • · Replies 5 ·
Replies
5
Views
2K
  • · Replies 1 ·
Replies
1
Views
3K
  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 9 ·
Replies
9
Views
2K
  • · Replies 2 ·
Replies
2
Views
2K
  • · Replies 1 ·
Replies
1
Views
2K