How to get the data back out of an R, ggplot2 or gnuplot plot

The script is gone, the data frame is gone, and the PDF of the plot is all that is left. The points are still in it.

Drop in a graph or a PDF

Why the PDF is enough

When a PDF holds the chart as a drawing (most figures in papers do), the values are read from the drawing itself. Nothing is estimated from pixels, so a point is as precise as the file is.

What we measured

Steps

  1. Drop in the PDF of the plot, or the whole report it sits in.
  2. Each series comes back under its legend name.
  3. Download Excel or CSV, or copy the table.

Limits

A figure of several panels drawn by R in one go (facets) has not been measured yet: check each panel against the rings.

A plot saved as PNG is a picture. A picture (a screenshot, a scan, a PNG or JPEG) is read by an AI model. Every value is then drawn back on the picture as a ring, so a wrong one is easy to see and to correct in the table.

Questions

My plot was saved with ggsave as a PNG. Can it be read?

Yes, as a picture, which is less exact. If you can run the script again, save a PDF (ggsave("plot.pdf")) and the values are read from the drawing.

Related