Mathematica Stack Exchange is a question and answer site for users of Mathematica. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Can I insert a button in an image at specified location? I have tried but it shows Button is not a graphic function.

share|improve this question
up vote 12 down vote accepted

Lets get an image:

img = ExampleData[{"TestImage", "Lena"}];

Overlay is pretty easy to use for location specification. In the case below I used scaled coordinates:

Overlay[{img, Button[Style["Image Histogram", Blue, Italic, 34], 
   CreateDialog[ImageHistogram[img]]]}, All, 2, Alignment -> {.7, -.8}]

enter image description here

Here is a simple line to understand better how to place the button in different locations:

Overlay[{img, Button[Style["Image Histogram", Blue, Italic, 8], 
     CreateDialog[ImageHistogram[img]]]}, All, 2, Alignment -> #] & /@Tuples[{.7,-.7}, 2]

enter image description here

share|improve this answer

You can use an inset:

   RandomImage[CauchyDistribution[0, .2], {100, 100}, 
    ColorSpace -> "RGB"], Center], 
  Inset[Button["Click Here", Print[10!]], {Center, -0.5}]}, 
 Frame -> True]
share|improve this answer

or maybe you don't want to put it on the image, but somewhere near it use this :

{Button["Transform", CreateDialog[ImageHistogram[img]]], Show[

Which works exactly the same but looks a little different.

share|improve this answer

Your Answer


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.