Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

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.

Update

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?

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

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.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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