5
$\begingroup$

I'm trying to use Mathematica to analyze some physics data from an experiment, more precisely, I have to fit a 2D data series with a one dimension function.

At the moment I'm able to load and plot correctly all the data, using the following command:

ListPlot3D[Img3, Mesh -> 20, PlotStyle -> Orange, InterpolationOrder -> 2, 
     MaxPlotPoints -> 150]

Where Img3 is a list with about 523000 {x, y, z} points. I obtain the following 3-D plot:

First view of the plot Another view of the plot

I would like to make a section of the plotted surface with a vertical plane (and I will have to adjust the vertical plane x,y direction to obtain a good cross intersection with the little "waves" on the top of the surface), and fit the profile of the intersection with a gaussian function + another function (this 3Dplot is the intensity profile of two interfering laser beams).

Is that possible? I've looked around a lot to search how to do it, but I didn't find anything that matches with my needs, right now I'm not able to get the profile of the intersection of this ListPlot3D surface with a plane. (I will manage by my own to fit the profile)

$\endgroup$
5
$\begingroup$

I guess what you are looking for can be easily achieved (and adjusted) with the RegionFunction option. Let me give an example using Plot3D. It should work similarly with ListPlot3D:

 Manipulate[
 Plot3D[Sin[10 x + 0.1 y]^2*Exp[-(x^2 + y^2)], {x, -2, 2}, {y, -2, 2},
  PlotRange -> {Automatic, Automatic, {0, 1}}, 
  PlotPoints -> 25,
  RegionFunction -> Function[{x, y, z}, z < height],
  BoundaryStyle -> Directive[Thick, Red]
  ],
 {{height, 1}, 0, 1}
 ]

Mathematica graphics

Edit

@MarcoB just pointed out that you are not interested in a graphics but the points of your cross section. One pretty easy way to get started is to forget the ListPlot3D and just concentrate on what you want:

A contour of your function in a certain height z. So let's do this instead and extract the points of those contours. I'm using the exact same function and it should work for you too when you use ListContourPlot:

gr = ContourPlot[
  Sin[10 x + 0.1 y]^2*Exp[-(x^2 + y^2)] - .3 == 0, {x, -2, 2}, {y, -2,
    2}, PlotPoints -> 50, MaxRecursion -> 3]

Mathematica graphics

Now we use the fact that those closed contours are stored as separate point list. The variable section will be a list of paths, where each path is a list of 2d points:

sections = Cases[Normal[gr], Line[pts__] :> pts, Infinity];
ListLinePlot[sections]

Mathematica graphics

$\endgroup$
  • $\begingroup$ Would it be possible to extract the numerical values corresponding to those boundaries from the OP's ListPlot3D or from the data itself, however? My understanding of the question was that the OP needed to extract the shape of those profiles to be able to fit them to his expression. $\endgroup$ – MarcoB May 17 '15 at 23:42
  • $\begingroup$ @MarcoB I see. Finding and tracing the contours so that you get a (interpolating) function or a path of points is a different story. It can be done by extracting the points from a contour plot, but I'm not sure I would rely on this for a scientific project. $\endgroup$ – halirutan May 18 '15 at 0:15
  • $\begingroup$ Looks great! Thank you for following up on this point. As for the robustness of this approach when fed experimental data, I guess that will be for the OP to investigate. (+1, of course) $\endgroup$ – MarcoB May 18 '15 at 0:29
  • 1
    $\begingroup$ My interpretation of the question was that he wanted to slice the surface with a plane perpendicular to the $x$-$y$ plane, so I thought he could form an InterpolatingFunction[] from his data, and then maybe apply that to the result of RotationMatrix[θ].({x, y} - pt) for some value of θ and pt. $\endgroup$ – J. M. will be back soon May 18 '15 at 3:44
  • $\begingroup$ @Guesswhoitis. If this is the case then the problem is of course much easier. $\endgroup$ – halirutan May 18 '15 at 7:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.