【发布时间】:2021-11-27 12:39:54
【问题描述】:
我想在我的图像中移动一个矩形。我发现了如何使用下面的代码在我的图像中获得一个矩形。但是现在我想知道我是否也可以将矩形旋转 30 度。
import matplotlib.pyplot as plt
import matplotlib.patches as patches
from PIL import Image
im = Image.open(r'path...\aero1.jpg')
# Create figure and axes
fig, ax = plt.subplots()
# Display the image
ax.imshow(im)
# Create a Rectangle patch
rect = patches.Rectangle((200, 200), 40, 30, linewidth=1, edgecolor='r', facecolor='none')
# Add the patch to the Axes
ax.add_patch(rect)
plt.show()
【问题讨论】:
标签: python matplotlib rotation shapes