How to extract data from a MATLAB figure

If you still have the .fig file, the data is inside it and MATLAB will hand it back. When all that is left is the figure in a paper, this reads it from the PDF.

Drop in a graph or a PDF

If you have the .fig file

Open it without showing it and ask each line for its data: fig = openfig('name.fig', 'invisible'); h = findobj(fig, 'Type', 'line'); x = get(h, 'XData'); y = get(h, 'YData'). That is exact and needs no digitizer.

If you have only the PDF

  1. Drop in the paper's PDF, or the figure's own PDF.
  2. Each line comes back with its markers as one series, under its legend name.
  3. Check the rings drawn on the figure, then download Excel or CSV.

What we measured

Limits

A legend set with MATLAB's LaTeX interpreter is stored as drawn shapes, not as text. The lines are still read, but their names cannot be, so they come back unnamed and the result says so.

Three-dimensional plots are refused: a point in one cannot be read off two axes.

An Octave figure saved as EPS holds its axis numbers as shapes too. Save it as PDF instead, or drop in a screenshot to have it read as a picture.

Questions

Does it read .fig or .mat files?

No. Those hold the data itself, and MATLAB reads them directly, as shown above. This is for when only the published figure is left.

Is it free?

Reading a figure from a PDF is free and unlimited.

Related