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.

I've got this picture:

JuliaSet

The image has a resolution of 2001x2001. The left most pixel has an x-value of -2, and the right most pixel has an x-value of 2. Same goes for the y-values. Now I am trying to load this image into Mathematica and get it on the right scale inside a graphics environment. I've tried using inset like this:

julia = Import["http://i.stack.imgur.com/NLMXG.png"];
Graphics[{Blue, Rectangle[{-2, -2}, {2, 2}], 
    Inset[julia, Center, Center, 4]}, PlotRange -> {{-3, 3}, {-3, 3}}, 
  Axes -> True, AxesStyle -> Orange]

This still gives a little blue border around some sides, giving me the impression that it is not centered properly. Is there a better way to do this?

share|improve this question
1  
I changed Julia to julia. It's a good habit to avoid starting variable names with capital letters :) –  Öskå Jun 16 at 13:48

1 Answer 1

up vote 2 down vote accepted

Inset is not suitable for reliable and precise positioning. Use Raster to include bitmap data in an image. It lets you specify the coordinates of the corners:

Graphics[
 Raster[ImageData[julia], {{-2, -2}, {2, 2}}],
 Frame -> True,
 GridLines -> Automatic,
 Method -> {"GridLinesInFront" -> True}
]

enter image description here

Note: the Graphics Method option I used is undocumented, so it might change in the future. It is used by functions like DensityPlot to make sure the grid lines are not obscured by other graphics elements.

share|improve this answer
    
@Öskå What version do you have? I tried with 8 and 9. –  Szabolcs Jun 16 at 14:30
    
@Öskå So is that the leftmost pixel or the leftmost black pixel? –  Szabolcs Jun 16 at 14:35

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.