Mathematica 3D plotting question

Join the discussion
Ask a follow-up here, or get your own question answered by working scientists, mathematicians and engineers — people, not an autocomplete.
Real named experts · corrections over time · the nuance an AI answer skips
3 replies · 6K views
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.
 
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]]