Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

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:

ListContourPlot[recovereddata]

or preferably

ListContourPlot[ recovereddata, DataRange -> {{yMin, yMax}, {xMin, xMax}},
                 AxesLabel -> {"y", "x"}, PlotRange -> All, 
                 PlotLegends -> Automatic, ColorFunction -> "BlueGreenYellow"]
share|improve this question
    
Do I understand correctly that you have the generated Mathematica contour plots in a Notebook still? –  Mr.Wizard Dec 4 '13 at 18:30
    
Yes only plots, but I have not the list of coordinates. –  Mushegh Dec 4 '13 at 18:54
    
FullForm[plot] will reveal the data (paste in the graphic if thats all you have). –  george2079 Dec 4 '13 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. –  george2079 Dec 4 '13 at 19:55
2  
@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? –  Mr.Wizard Dec 4 '13 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 = 
  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..

share|improve this answer
    
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) –  Mushegh Dec 6 '13 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. –  george2079 Dec 7 '13 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:

ListPointPlot3D[data]

enter image description here

Recreating the contour plot:

ListContourPlot[data]

enter image description here

share|improve this answer
    
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) –  Mushegh Dec 6 '13 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. –  Simon Woods Dec 6 '13 at 16:25
    
Sorry, where and how I can upload my plot? I am registered here recently –  Mushegh Dec 9 '13 at 13:37

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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