# Importing Graphics from an Online Paper

I'm trying to reproduce a few graphs in Mathematica after running my Fortran code. Ideally, I want exact quantitative agreement with the results already published in the literature. For example, I am trying to reproduce the four graphs on pp.50 of

http://ediss.sub.uni-hamburg.de/volltexte/2004/1133/pdf/dissertation.pdf

Is there any way I can copy/import snippets of these graphics and initialize these graphs in Mathematica so I can superimpose both the graphs and see if I have quantitative agreement. Or is that too far fetched an option?

• If I understand your porblem I see one solution : first try to extract the graphics you want to import with the help of an external program --- like image extractor --- then you can use the command inset. Have a look at the question mathematica.stackexchange.com/questions/65669/… Sep 24 '16 at 8:44
• There is one way based on the use of the function copyCurve published here: mathematica.stackexchange.com/questions/44355/…. It enables you to capture the points from the PDF plot as a list and to use them then in Mma. In your case of a highly oscillating functions it will require some work, to catch the curves in enough details. Sep 24 '16 at 11:22
• If possible, ask the author to provide you pictures for comparison. This is also honest way to conduct science: typically you need a permission for reproduction of published work. The copyright of dissertation belongs to the library of the corresponding university. Sep 24 '16 at 11:27
• @AlexeiBoulbitch This is a vector plot, all points are there. Sep 24 '16 at 11:30
• Nov 3 '16 at 7:35

The graphics we want are on page 50, but there are six prefatory pages labelled i through vi. So we will start by loading page 56 into memory:

$url = "http://ediss.sub.uni-hamburg.de/volltexte/2004/1133/pdf/dissertation.pdf";$page50 = Import[$url, {"Pages", 56}] // First  We used First because importing PDF "Pages" returns of list of pages, in this case of one element. The imported page is a Graphics expression: $page50 // Head

(* Graphics *)


We can extract individual graphical elements from that expression. For example, here is the chapter title:

$page50[[1, 2]] // Graphics  It does not take much experimentation to locate our plots: $page50[[1, 3;;30]] // Graphics


... or to extract just the first curve:

$curve1 =$page50[[1, 3]];
$curve1 // Graphics  The curve points can be extracted from this curve expression: $curve1

(* Style[{JoinedCurve[{{{0, 2, 0}, {0, 1, 0}, ...}},
{{{138.816, 709.0320000000002}, {139.023, 707.23},
{139.20000000000002, 701.972}, ...}}, CurveClosed -> {0}]},
JoinForm[{"Miter", 10.}], Thickness[0.0014893882352941176],
RGBColor[0.47100000000000003, 0.47100000000000003, 1., 1.]]
*)

$curve1[[1, 1, 2, 1]] (* {{138.816, 709.032}, {139.023, 707.23}, ..., {286.514, 655.299}} *)$curve1[[1, 1, 2, 1]] // ListLinePlot


We need to rescale the points to the original axes:

$points1 // Transpose // Query[{1 -> (100 Rescale[#]&), 2 -> (2 Rescale[#] - 1 &)}] // Transpose // ListLinePlot  In the general case, rescaling can be more challenging. See (85329) for a more general treatment. We have successfully recovered the original data points of the first curve and replotted them using Mathematica. For completeness, here are the "addresses" of all of the individual curves: $page50[[1, {3, 4, 10, 11, 17, 18, 24, 25}]] // Map[Graphics] // Column


• I guess we're lucky in this case that the curves weren't rasterized. Oct 7 '16 at 5:59
• Splendid answer. Although I could do my work by simply eye balling the graphs I made on Mathematica with those in the paper because they were a match. I'll use your methods for future purposes. Oct 7 '16 at 6:16
• (+1) Beautiful answer! But it is worth to note that the rescaling method used here is based on the assumption that the range of coordinates of the points is exactly equal to the plotting range what usually isn't the case. In the general case more involved approach based on reconstruction of the coordinate system from the axes' ticks is necessary, I show it in this answer. Nov 3 '16 at 7:48
• @AlexeyPopkov I added a reference to your answer to my response. Thanks. Nov 3 '16 at 14:00