Mathematica 3D plotting question

Click For Summary

Discussion Overview

The discussion revolves around creating a 3D graph in Mathematica that combines a scatter plot with a plane. Participants explore methods for importing data from an Excel file and share code snippets to achieve the desired visualization.

Discussion Character

  • Technical explanation, Exploratory, Homework-related

Main Points Raised

  • One participant seeks assistance with code to create a 3D graph that includes both a scatter plot and a plane, mentioning the possibility of importing data from an Excel file.
  • Another participant provides a method to emulate data import by generating random data and saving it as a CSV file, along with code snippets for loading the data into Mathematica.
  • A participant shares their implementation of a plane using the Plot3D function and expresses a desire to add opacity to the plane, questioning how to do so.
  • The same participant later finds the solution to add opacity using the PlotStyle option with Directive.

Areas of Agreement / Disagreement

The discussion appears to be collaborative, with participants building on each other's contributions. There is no indication of disagreement, as participants provide helpful suggestions and solutions.

Contextual Notes

Participants discuss specific code implementations and options available in Mathematica, but there may be limitations in understanding how to apply certain features, such as opacity in Plot3D.

Who May Find This Useful

Users of Mathematica interested in 3D plotting, particularly those looking to combine different types of visualizations or import data from external sources.

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