I want to rotate a matplotlib rectangular patch object about its lower left corner using the rotate_deg_around() function. However, the patch is always rotating about some different point. Any idea why the rotate_deg_around() function is not producing the desired result?
My code is as follows:
f,(ax1) = plt.subplots(1,1,figsize=(6,6))
f.subplots_adjust(hspace=0,wspace=0)
ts = ax1.transData
coords = ts.transform([1,1])
tr = mpl.transforms.Affine2D().rotate_deg_around(coords[0], coords[1], 10)
t = ts + tr
rec0 = patches.Rectangle((1,1),3,2,linewidth=1,edgecolor='r',facecolor='none')
ax1.add_patch(rec0)
#Rotated rectangle patch
rect1 = patches.Rectangle((1,1),3,2,linewidth=1,edgecolor='b',facecolor='none',transform=t)
ax1.add_patch(rect1)
# Rectangles lower left corner
plt.plot([1], [1], marker='o', markersize=3, color="green")
plt.grid(True)
ax1.set_xlim(0,6)
ax1.set_ylim(-1,4)
resulting in the following figure:
I have followed Unable to rotate a matplotlib patch object about a specific point using rotate_around( )
Any help is much appreciated.