I am trying to create a notebook which will graphically display the effect of simple geometric maps, for the purpose of teaching linear algebra. Here is what I thought would work.

I created an image called map. It is 920 pixels wide and 797 tall. Here it is displayed on background coordinate axes.

Show[map, Axes -> True, PlotRange -> {{-1200, 1200}, {-1200, 1200}}]

enter image description here

Now, I want to show this image rotated by $\pi/6$ around $(0,0)$. Here is what I thought would work:

  ImageForwardTransformation[map, ({{Cos[Pi/6], -Sin[Pi/6]}, {Sin[Pi/6], Cos[Pi/6]}}.#) &,
    PlotRange -> All],
  Axes -> True, PlotRange -> {{-1200, 1200}, {-1200, 1200}}]

Here is the output:

enter image description here

As you can see, the origin is in the wrong place! I expected ImageForwardTransformation to create a new image whose image coordinates would be rotated from the old image coordinates. For example, if $0 < \theta < \pi/2$, and the old coordinates are $[0,w]\ \times\ [0,h]$, then the new ones would be $[-(\sin \theta) h, (\cos \theta) w] \ \times\ [0, (\sin \theta) w + (\cos \theta) h]$. Instead, it seems that 'ImageForwardTransform[]' always translates the lower left pixel to be at $(0,0)$, so the new coordinates are $[0, (\cos \theta) w+(\sin \theta) h] \ \times\ [0, (\sin \theta) w + (\cos \theta) h]$.

I tried a bunch of variants on the above code, but I think I am missing something basic and it probably isn't useful to copy over all the failures. Is there an easy way to make 'ImageForwardTransform[]' work correctly with axes and other graphics objects? Or is there some variant function I should be using instead? (I tried ImageGraphics and Rotate instead, with the idea of using graphics objects everywhere instead of images, but that didn't work either; I'll add details of the failure if people want.)

  • $\begingroup$ It might help to color in the Background. What you would see is that the image is rotated and a new image is returned containing the rotated image in a circumscribed rectangular box with vertical and horizontal sides. The new image has the standard coordinate system, starting at (0, 0) in the bottom left and counting pixels. (Also, images are not graphics, so it sometimes takes some work to get them to play nicely together.) $\endgroup$
    – Michael E2
    Sep 6, 2020 at 16:57

1 Answer 1


Maybe something like this:

   Inset[ExampleData@{"TestImage", "Mandrill"}, {0, 0}, {0, 0}, 70],
  }, Axes -> True, PlotRange -> 100]

Rotated Mandrill

  • $\begingroup$ Thank you! Inset[] looks like a command I need to get to know better. $\endgroup$ Sep 7, 2020 at 19:35

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.