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"]

enter image description here

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


or preferably

ListContourPlot[ recovereddata, DataRange -> {{yMin, yMax}, {xMin, xMax}},
                 AxesLabel -> {"y", "x"}, PlotRange -> All, 
                 PlotLegends -> Automatic, ColorFunction -> "BlueGreenYellow"]
  • $\begingroup$ Do I understand correctly that you have the generated Mathematica contour plots in a Notebook still? $\endgroup$
    – Mr.Wizard
    Dec 4, 2013 at 18:30
  • $\begingroup$ Yes only plots, but I have not the list of coordinates. $\endgroup$
    – Mushegh
    Dec 4, 2013 at 18:54
  • $\begingroup$ FullForm[plot] will reveal the data (paste in the graphic if thats all you have). $\endgroup$
    – george2079
    Dec 4, 2013 at 19:43
  • $\begingroup$ Sorry, after posting that I took a look and I think the ListContourPlot object does not contain the original data - you may be SOL. $\endgroup$
    – george2079
    Dec 4, 2013 at 19:55
  • 2
    $\begingroup$ @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? $\endgroup$
    – Mr.Wizard
    Dec 4, 2013 at 20:42

2 Answers 2


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 = 
       Append[#1, cvals[[#2[[1]]]]] &, (Flatten[# /. Line -> List, 2]) & /@
 clines , {2}], 1];

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..

  • $\begingroup$ 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) $\endgroup$
    – Mushegh
    Dec 6, 2013 at 15:18
  • $\begingroup$ "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. $\endgroup$
    – george2079
    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]]

enter image description here

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:


enter image description here

Recreating the contour plot:


enter image description here

  • $\begingroup$ 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) $\endgroup$
    – Mushegh
    Dec 6, 2013 at 15:26
  • $\begingroup$ @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. $\endgroup$ Dec 6, 2013 at 16:25
  • $\begingroup$ Sorry, where and how I can upload my plot? I am registered here recently $\endgroup$
    – Mushegh
    Dec 9, 2013 at 13:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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