I have two different lists as list1 and list2. Their ListPlot3D of them are: enter image description here and enter image description here

As shown in these plots, there are some points of which {x,y} pairs are first pairs that z get zero by them. For example Red ones for list1 and Green ones for list2. The desired and so important plot which must be extracted from two previous plots is as schematic: enter image description here

As it is clear the desired is the taking two firstly roots of other shapes in one plot as pairs of {x,y}.


If I understand your question correctly, here is a possible approach to extracting the {x, y} list of values corresponding to the zeroes of your function when the function is only available through data points.

First of all, I will generate a data list, since you did not provide one. Let's consider for instance the following function as an example:

f[x_, y_] := 20 x^2 - 3 (y - 2/3)^3 + 750
Plot3D[f[x, y], {x, y} \[Element] Rectangle[{0, 0}, {10, 10}], 
  Mesh -> {{0.}}, MeshFunctions -> (f[#1, #2] &), 
  MeshStyle -> {Red, Thick},
  AxesLabel -> {x, y, z}

the 3D plot with zeroes

Here is am using mesh functions to highlight the position of a zero contour for your function. However, you don't have the functional expression, but just a list:

list1 = Table[{x, y, f[x, y]}, {x, 0, 10, 0.5}, {y, 5, 10, 0.2}] // Flatten[#, 1] &;

ListContourPlot can calculate the contour line you want, i.e. the list of points $(x, y)$ for which your function is zero:

list1plot = ListContourPlot[list1, Contours -> {0.}]

contour 2D

We can then extract the coordinates of the calculated line:

zeroes = Cases[
   Line[a__] :> a,

We use Normal here to transform the GraphicsComplex expression generated by ListContourPlot behind the scenes into a simpler Graphics expression, which is easier to handle to extract information from.

Finally, we can plot the zeroes list:

ListPlot[zeroes, AxesLabel -> (Style[#, 18, Red] & /@ {x, y})]



I apologize, I missed the links to your data the first time around. Loading those lists as list1 and list2, and using ListLinePlot, rather than ListPlot, then one obtains:

     Normal@ListContourPlot[#, Contours -> {0.}],
     Line[a__] :> a, Infinity
   ]] & /@ {list1, list2};

  PlotRange -> All, PlotLegends -> {"list1", "list2"},
  AxesLabel -> (Style[#, 18, Red] & /@ {x, y})

new lists

  • $\begingroup$ Besides thanks for your answer I am not understand why you said "since you did not provide one" because in list1 I provided in the address: "speedyshare.com/kyVar/list1.txt" and "speedyshare.com/mDH2n/list2.txt" $\endgroup$ – Unbelievable May 26 '16 at 19:27
  • $\begingroup$ Or use your mesh?f[x_,y_]:=20 x^2-3 (y-2/3)^3+750 plot=Plot3D[f[x,y],{x,y}\[Element]Rectangle[{0,0},{10,10}],Mesh->{{0.}},MeshFunctions->(f[#1,#2]&),MeshStyle->{Red,Thick},AxesLabel->{x,y,z}]; zeroPoint=Cases[Normal[plot],_Line,Infinity][[-1,-1]]; Plot3D[f[x,y],{x,y}\[Element]Rectangle[{0,0},{10,10}]]~Show~ListPointPlot3D[PadRight[#,3]&/@zeroPoint,PlotStyle->Thick] $\endgroup$ – yode May 26 '16 at 19:55
  • $\begingroup$ @yode Yes, that would work IF you had a functional expression to use in Plot3D, but OP only has lists, not a function... $\endgroup$ – MarcoB May 26 '16 at 20:20
  • $\begingroup$ @Irreversible You are right, I missed the links when I read your post. I updated my answer using your data. Sorry for the confusion! $\endgroup$ – MarcoB May 26 '16 at 20:31
Show[ListContourPlot[#, Contours -> {0}, ContourShading -> None, 
    ContourStyle -> Directive[Thick, #2]] & @@@
    {{list1, Red}, {list2, Green}}]

Mathematica graphics


You can first find all the roots by their z value, and then select out the first point that touches zero. For example:

ε0 = 1.*^-3;
  First /@ SplitBy[
    Sort[Select[ls, Abs[#[[3]]] < ε0 &][[All, 1 ;; 2]]],
     First], {ls, {list1, list2}}], PlotRange -> All]

enter image description here


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.