2
$\begingroup$

I have (x,y) data here: http://pastebin.com/raw/NUNC5Jb2

Now I would like to overplot a ListLinePlot of this data on top of an image:

enter image description here

I did the following:

data = Import["http://pastebin.com/raw/NUNC5Jb2"];

{minx, maxx} = MinMax[data[[All, 1]]];
{miny, maxy} = MinMax[data[[All, 2]]];

ListLinePlot[data, PlotRange -> {{minx, maxx}, {miny, maxy}}, 
 AspectRatio -> ImageAspectRatio@image, 
 PlotStyle -> {RGBColor[1, 0, 0]}, Frame -> True, 
 Prolog -> {Texture[image], 
   Polygon[{Scaled[{0, 0}], Scaled[{1, 0}], Scaled[{1, 1}], 
     Scaled[{0, 1}]}, 
    VertexTextureCoordinates -> {{0, 0}, {1, 0}, {1, 1}, {0, 1}}]}, 
 Ticks -> None]

The result is:

enter image description here

Does also another solution exists?

$\endgroup$
  • 4
    $\begingroup$ You can replace your prolog with Prolog->{Inset[image, Sequence @@ (ImageScaled /@ {{0, 0}, {0, 0}, {1, 1}})]} which is slightly less verbose. Is there anything in particular you're looking for? $\endgroup$ – N.J.Evans Feb 9 '17 at 16:12
  • 1
    $\begingroup$ and even slightly less verbose than the above would be Prolog -> Inset[image, Automatic, Automatic, Scaled[1]] $\endgroup$ – Jason B. Feb 10 '17 at 17:50
  • $\begingroup$ @Jason B. This command shows a small gap at right and upper part between image and axes. When I modify it to Prolog -> {Inset[image, Scaled[{.5, .5}], Automatic, Scaled[1]]}] then the gaps vanish. $\endgroup$ – mrz Feb 11 '17 at 20:29
  • $\begingroup$ @mrz I used an ImagePadding -> None and it seemed to be the same as your plot $\endgroup$ – Jason B. Feb 11 '17 at 20:56