Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Mathematica 3D plotting question

  1. Aug 1, 2010 #1
    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.
     
  2. jcsd
  3. Aug 1, 2010 #2
    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]
     
  4. Aug 1, 2010 #3
    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?
     
  5. Aug 1, 2010 #4
    Nevermind, I found it!

    PlotStyle -> Directive[Opacity[0.5]]
     
Share this great discussion with others via Reddit, Google+, Twitter, or Facebook