3
$\begingroup$

I have a bunch of points, e.g. minimal example:

x = {{0, 0, 1}, {1, 1, 0.5}, {-1, -1, 0.5}, {-1, 1, 0.5}, {1, -1, 
   0.5}}

and I am plotting them as a ListPlot3D:

ListPlot3D[x]

Giving me this:

enter image description here

--

What I would like is a 1D plot taken as a cut of this, like so:

enter image description here

The issue here being that there are no points at x = 0, so I'd have to take a projection on that plane? Or is there an interpolation method?

$\endgroup$
5
$\begingroup$

You can use Interpolation directly on your original data:

x = {{0, 0, 1}, {1, 1, 0.5}, {-1, -1, 0.5}, {-1, 1, 0.5}, {1, -1,  0.5}};
iF = Quiet @ Interpolation[x];

Row[{ListPlot3D[x, ImageSize -> 300, PlotLabel -> "ListPlot3D", 
   MeshFunctions -> {# &}, Mesh -> {{-.5, 0, .5}}, MeshStyle -> Thick],
  Plot3D[iF[u, v], {u, -1, 1}, {v, -1, 1}, PlotPoints -> 100, 
   ImageSize -> 300, PlotLabel -> "Plot3D", 
   MeshFunctions -> {# &}, Mesh -> {{-.5, 0, .5}}, MeshStyle -> Thick]}]

enter image description here

Row[Plot[iF[#, t], {t, -1, 1}, ImageSize -> 220,     
    PlotRange -> {.5, 1}, PlotLabel -> Row[{"x = ", #}]] & /@ {-.5,  0, .5}]

enter image description here

| improve this answer | |
$\endgroup$
  • $\begingroup$ Hey thanks, but I cannot seem to be able to apply to my set of points, which is quite dense.. $\endgroup$ – SuperCiocia Jun 11 '18 at 11:29
  • $\begingroup$ @SuperCiocia, can you post an example of a small data set that shows the issue? $\endgroup$ – kglr Jun 11 '18 at 11:41
  • $\begingroup$ pastebin.com/3bvjKgzD $\endgroup$ – SuperCiocia Jun 11 '18 at 11:57
  • $\begingroup$ @SuperCiocia, the error message "Interpolation::indp: There are duplicated abscissa points in..." suggests that need to eliminate the duplicate abscissa (e.g., iF =Interpolation@DeleteDuplicates[data, #[[;; 2]] == #2[[;; 2]] &]) for Interpolation two work. $\endgroup$ – kglr Jun 11 '18 at 12:33
4
$\begingroup$

You can interpolate

x = {{#, #2}, #3} & @@@ {
  {0, 0, 1}, {1, 1, 0.5}, {-1, -1, 0.5}, {-1, 1, 0.5}, {1, -1, 0.5}
};

f = Interpolation[x];

Plot[f[0, y], {y, -1, 1}]

enter image description here

| improve this answer | |
$\endgroup$

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.