I needed to get some data out of a figure from someone else’s paper (e.g. some lines defining a function), so I figured I’d try and extract that data from the .eps source file (these are generally available from the if the person posted their paper on arXiv and was sensible enough to use the eps format when they produced the figure in the first place). Here’s how I did it (there may well be other solutions, but I’m mainly documenting it here so I remember myself):
- Open the eps file in inkscape
- In the “Edit” tab click on “XML Editor” at the bottom of the list
- On your image click on the line, or picture element you want to extract
- In the XML editor window this will show the path element for that line
- click on the “d” attribute and the coordinate information for the line will be shown in the box below (see here for a description of the path element) – if the line starts with a lower case m then it means each set of x-y coordinate point values (given as e.g. x1,y1 x2,y2 x3,y3 etc) is relative to the last one.
- To plot these you may want to copy the coordinate points into, for example, Matlab:
vals = [x1,y1 x2,y2 x3,y3 etc]
, however if they are relative points you will have to plot them using thecumsum
function e.g.plot(cumsum(vals(1:2:end)), cumsum(vals(2:2:end)))
- You’ll also need to work out how to transform the x-y values in the file, which are given in pixels defined from some arbitrary position, into the actual units of the function
One Reply to “Extracting data from an .eps file”