DEV Community

Cover image for How to turn a plot image into pgfplots with the real data
Chintu Gurbani
Chintu Gurbani

Posted on Originally published at catchtex.com

How to turn a plot image into pgfplots with the real data

You want to reproduce a plot from another paper in your own document, in your own style, or compare your results against it. Pasting the image looks out of place and cannot be edited. Here is how to get a pgfplots figure with the measured data points instead.

The quick way

  • Snip the plot in CatchTeX's PDF viewer (Ctrl+O) or from the screen (Ctrl+Alt+T). Include
    the axes, tick labels and legend.

  • Auto mode recognises a plot; you can also pick the Plot chip.

  • Compare the compiled pgfplots preview with the original snip.

  • Copy LaTeX (Ctrl+Shift+C): you get a pgfplots axis with one
    \addplot per series, ready for Overleaf, together with the packages it needs.

\begin{tikzpicture}
\begin{axis}[xlabel={Epoch}, ylabel={Accuracy},
xmin=0, xmax=50, ymin=0, ymax=1, legend pos=south east]
\addplot coordinates {(0,0.08) (5,0.41) (10,0.66) (20,0.83) (50,0.91)};
\addlegendentry{Ours}
\addplot coordinates {(0,0.07) (5,0.29) (10,0.48) (20,0.66) (50,0.78)};
\addlegendentry{Baseline}
\end{axis}
\end{tikzpicture}
Enter fullscreen mode Exit fullscreen mode

How it measures the data

CatchTeX reads the axis tick labels, maps pixel positions to data values, separates the series
and samples each curve. It is deterministic image analysis, not a guess by an
AI model, so the same snip always gives the same numbers. On our test set it finds 37 of 38 series,
with a mean error of 0.45 % of the axis range, and reads all 40 axis labels.

The data are as precise as the picture: a small, low-resolution plot gives coarser values. Zoom
in before you snip, and check the preview against the original.

Other ways, compared

Method Data you can edit LaTeX output Effort
Include the image (\includegraphics) No Picture only, other fonts None
WebPlotDigitizer / Engauge Digitizer Yes (CSV) No: write the pgfplots code yourself Calibrate axes, click or trace each series
Ask the authors for the data Yes No Days, if they answer
CatchTeX Yes, in the code Complete pgfplots figure, compiled One snip

Tips

  • Restyle freely: change colours, line styles and fonts in the axis options so the
    figure matches the rest of your document.

  • Cite the source of the data in the caption, as you would for a reproduced figure.

  • Need the numbers in a table instead? Copy the coordinates from the code into a
    pgfplotstable or a spreadsheet.

Try it on your own paper

CatchTeX is free for Windows, Mac and Linux: every mode, works offline, nothing to set up.

[

Download CatchTeX free](https://catchtex.comdownload?ref=guide-plot)


Originally published at catchtex.com/guides/plot-image-to-pgfplots.

CatchTeX runs offline on Windows, Mac and Linux. Download it free at catchtex.com.

Top comments (0)