This question may not be well describe, but I will try to explain as best as possible.

Suppose somebody gives me some image (say of a plot on the complex plane), and also describes the dimensions of it, say the boundary of the picture vertically is from the origin to the point $2i$ and horizontally from $-1$ to $1$.

Now suppose I want to add some graphic elements such as a line or a Bezier curve using Mathematica. Is there some way to tell Mathematica the scale of the image so that the defining points of graphic elements are consistent with the coordinates of image?

(Apologies if this has an obvious solution, I am currently running a large piece of code so I cannot experiment with this, but I think in past experience this is not an obvious thing one is able to do.)


1 Answer 1


You can use RegionPlot to fit the texture of the image onto a rectangle of the right dimensions, then use Show to combine the rectangle with the Graphics:

(* The image you've been given. I make up a fake one here: *)
img = Image[
  ComplexPlot[Gamma[1/z], {z, -1 - 2 I, 1 + 2 I}, 
   PlotRangePadding -> None, Frame -> None]]

 RegionPlot[Rectangle[{-1,-2}, {1,2}], BoundaryStyle->None, PlotStyle->Texture[img]],

   BezierCurve[{{0, 3/2}, {3/2, 1}, {1/3, 1/2}, {1/3, -1}}]}]

textured background plot

  • $\begingroup$ Thank you for this! Related, is there some way to draw directly say a point or curve on an image and have Mathematica gives the coordinates of this point or (an approximation of) the curve? I would experiment with this but I still have the large program running so I can't... $\endgroup$
    – math
    Commented Aug 13, 2020 at 15:19
  • $\begingroup$ You mean like editing the image in ms paint and then using image processing to figure out the positions ? Maybe - it would depend on the image and how cluttered it is. I cannot say without the image though, and you should ask this in a separate question, though it has likely already been answered. $\endgroup$
    – flinty
    Commented Aug 13, 2020 at 15:33
  • $\begingroup$ Thanks for this, I've asked it as a new question here mathematica.stackexchange.com/questions/228469/… $\endgroup$
    – math
    Commented Aug 13, 2020 at 18:23
  • $\begingroup$ @math will you upvote/accept this answer or did you have difficulty getting it to work? $\endgroup$
    – flinty
    Commented Aug 15, 2020 at 12:44

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.