5
我试图在Matplotlib中绘制一个2D图像(从PNG导入)并将其旋转任意角度。我想创建一个简单的动画,显示一个对象随着时间的旋转,但现在我只是想旋转图像。我试过几个变化在下面的代码,但没有成功:在Matplotlib中旋转图像
import matplotlib.pyplot as plt
import matplotlib.transforms as tr
import matplotlib.cbook as cbook
image_file = cbook.get_sample_data('ada.png')
image = plt.imread(image_file)
imAx = plt.imshow(image)
rot = tr.Affine2D().rotate_deg(30)
imAx.set_transform(imAx.get_transform()+rot)
plt.axis('off') # clear x- and y-axes
plt.show()
我敢肯定,我失去了一些东西,但我一直无法从matplotlib文档和示例看着办吧。
谢谢!
貌似ndimage.rotate()是我是后。谢谢! – user2844064