I'm trying to plot an image that must be rotated around its corner in Python.
I could do a script that (kind of) do that job, but not around a pivot point as I wish:
import matplotlib.pyplot as plt
import PIL
picture= PIL.Image.open('images/sample-image.png')
maxsize = (40*10,30*10)
picture = picture.resize(maxsize,PIL.Image.ANTIALIAS)
comp = picture.im.size[0]
larg = picture.im.size[1]
plt.figure(figsize=(10,5),dpi=300)
plt.xlim((-100,500))
plt.ylim((-100,500))
plt.imshow(picture.rotate(0,expand=True))
plt.imshow(picture.rotate(-15,expand=True))
plt.imshow(picture.rotate(-30,expand=True))
plt.imshow(picture.rotate(-45,expand=True))
plt.imshow(picture.rotate(-90,expand=True))
plt.show()
The result that I've got was:
The result I wish is:
You can use the
transform
keyword to define a rotation about a certain point:Image source