Is it possible to plot an image, i.e., draw it's pixels against usual coordinates? My goal is to plot my image and my function in the same coordinates.


I drew an image of size 200x100 and drew a spot at 100,50. When plotting it should coincide with actual coordinates, but it doesn't.

enter image description here

i.e. image takes random size and random scale both unrelated with plot size and scale. While I need each pixel be located at it's correct coordinates, not only image corner.

Update 2

Why Image is not a Graphics primitive or directive?

  • $\begingroup$ Can you supply the code for your function, its plot, and your image? You haven't given us much to work with. $\endgroup$
    – m_goldberg
    Jun 25, 2013 at 13:46
  • 1
    $\begingroup$ The image pixels are square so you will need to use AspectRatio -> Automatic in your plot. $\endgroup$ Jun 25, 2013 at 15:18
  • 2
    $\begingroup$ If you would rather have the image distort to match the aspect ratio of the plot, you could use Prolog -> Raster@Reverse@ImageData@im $\endgroup$ Jun 25, 2013 at 15:19
  • $\begingroup$ @SimonWoods your last suggestion was what I looked for $\endgroup$
    – Suzan Cioc
    Jun 25, 2013 at 15:29
  • 1
    $\begingroup$ You have to set up AspectRatio if you specify the PlotRange: AspectRatio -> 1/Divide @@ ImageDimensions[im]. $\endgroup$
    – shrx
    Jun 25, 2013 at 19:01

1 Answer 1


I think you may want something like this:

Plot[Sin[x], {x, 0, 10}, 
 Prolog -> Inset[ex, {0, 0}, {0, 0}, {Automatic, 1}]]

First you plot your function and then, using Inset, you insert your image into the plot. The fourth parameter given to Inset is the size given in the coordinate system of the plot.

Prolog draws the image before the plot is drawn. Epilog would do the same but draw the image after the plot is drawn, on top of it.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.