3

I have data for x and y when z=z1, z=z2 and z=z3. I'd like to plot the data on a 3d graph and approximate the curves with a 3d surface and to know the equation of the surface. Will this be easier to implement on R or on Mathematica? For instance how can I do it in R? Thanks

Data (example):

For z=0
y   0.00    1.50    1.92    2.24
x   0.0000  0.0537  0.0979  0.2492

For z=2
y   0.00    2.21    2.83    3.07
x   0.0000  0.0173  0.0332  0.0655

For z=5
y   0.00    0.29    2.49    3.56
x   0.0000  0.0052  0.0188  0.0380
JasonMArcher
  • 14,195
  • 22
  • 56
  • 52
jpcgandre
  • 1,487
  • 5
  • 31
  • 55
  • 4
    SO isn't really set up to answer "which is better/easier/faster/cooler/bigger/stronger" type questions...as they are inherently full of opinions and may change over time. For example, I use R all day every day, so doing this in R will almost certainly be easier *for me*. Can you rework your question to include some data points and ask for advice on plotting them in 3D? Then you can decide for your purposes if using R or mathematics is easier. – Chase Sep 05 '12 at 11:46
  • Edited the question and added data. – jpcgandre Sep 05 '12 at 12:36
  • 1
    Great, good luck! [This question](http://stackoverflow.com/questions/1896419/plotting-a-3d-surface-plot-with-contour-map-overlay-using-r) may be a useful starting point for you as it pertains to R. – Chase Sep 05 '12 at 12:43

1 Answers1

5

In Mathematica:

Suppose you have a set of points qt:

ListPointPlot3D[qt]

Mathematica graphics

You could easily build an interpolation function:

Plot3D[Interpolation[qt][x, y], {x, -2, 2}, {y, -2, 2}, Ealuated -> True]

Mathematica graphics

If you need an explicit function model, you can propose one and calculate its parameters:

model = a x^2 + b y^2;
fit = FindFit[qt, model, {a, b}, {x, y}];
Show[Plot3D[model /. fit, {x, -2, 2}, {y, -2, 2}, PlotRange -> All], 
     ListPointPlot3D[qt, PlotStyle -> Directive[PointSize[Medium], Red]]]

Mathematica graphics

Edit

And it is fairly easy to plot nice graphs:

Mathematica graphics

Dr. belisarius
  • 60,527
  • 15
  • 115
  • 190