# how recover lost data of coordinates from contourplot of mention data?

I have made Contour Plot for a lot of data, like this

ListContourPlot[ data, DataRange -> {{yMin, yMax}, {xMin, xMax}},
AxesLabel -> {"y", "x"}, PlotRange -> All,
PlotLegends -> Automatic, ColorFunction -> "BlueGreenYellow"]


but now I lost my data (the coordinates). How I can recover those in such way that I can plot them by:

ListContourPlot[recovereddata]


or preferably

ListContourPlot[ recovereddata, DataRange -> {{yMin, yMax}, {xMin, xMax}},
AxesLabel -> {"y", "x"}, PlotRange -> All,
PlotLegends -> Automatic, ColorFunction -> "BlueGreenYellow"]

• Do I understand correctly that you have the generated Mathematica contour plots in a Notebook still? Dec 4, 2013 at 18:30
• Yes only plots, but I have not the list of coordinates. Dec 4, 2013 at 18:54
• FullForm[plot] will reveal the data (paste in the graphic if thats all you have). Dec 4, 2013 at 19:43
• Sorry, after posting that I took a look and I think the ListContourPlot object does not contain the original data - you may be SOL. Dec 4, 2013 at 19:55
• @george2079 I think the question is how to approximate the data from back calculation, rather than merely extracting it. It expect that it will be complicated. The data does not have to be perfect, only close enough to produce a similar plot. Mushegh, can you confirm my understanding? Dec 4, 2013 at 20:42

Try this:

plot = ListContourPlot[ Flatten[ Table[{x, y, Sin[Pi x] Cos[2 Pi y]} ,
{x, -1,  1, .1}, {y, -1, 1, .1}], 1]]
data = List @@ (First@Cases[plot, _GraphicsComplex]);
clines = ((Rest@#) & /@ Cases[data[[2]], {_Directive, ___}, Infinity])
/.  i_Integer :> data[[1, i]];
Graphics[  clines ]
cvals = Table[ i, {i, .8, -.8, -.2}]; (*table of contour line values*)
pointsets =
Flatten[MapIndexed[
Append[#1, cvals[[#2[[1]]]]] &, (Flatten[# /. Line -> List, 2]) & /@
clines , {2}], 1];
ListContourPlot[pointsets]


To be clear, this is not recovering the actual input data, it works by pulling the points used to construct the contour lines.

If you only have the graphic you can do  plot = (*paste graphic*) shift-enter

The contour values are there in "Tooltips", but I cant figure how to extract that info so I just set manually..

• Thank you very much, but it doesn't work for my case, I think it is because my contours are more complicated (see picture above) Dec 6, 2013 at 15:18
• "doesnt work" isn't much to go on.. Do you get a plot at all? One issue i see with your data is not that its complicated but that you have large boundary region with no contour lines. You might need to manually add some edge points to get it to look right. Dec 7, 2013 at 16:04

A similar approach to george2079, extracting the coordinates of the contour lines and getting the z values from the tooltips:

lcp = ListContourPlot[Array[Norm[{##}] &, {20, 20}, -5]]


data = Reap[Cases[Normal@DeleteCases[lcp, _Polygon, -1],
Tooltip[{_, lines__}, z_] :>
({lines} /. {x_Real, y_Real} :> Sow[{x, y, z}]), -1]][[2, 1]];


This is the data, you can see how it corresponds to the contour lines:

ListPointPlot3D[data]


Recreating the contour plot:

ListContourPlot[data]


• Thank you Simon Woods, it is plotting something but it is not the initial picture, I think it is because my contour plots are more complicated (see picture above, I have added it) Dec 6, 2013 at 15:26
• @Mushegh, perhaps you will need to interpolate the extracted data points, or do a fit. If you can provide a link to the original plot I would be happy to have another go. Dec 6, 2013 at 16:25
• Sorry, where and how I can upload my plot? I am registered here recently Dec 9, 2013 at 13:37