[英]Rotate an image in matplotlib?
我想旋转由plt.imshow()
生成的图像。 有可能吗? 我不想旋转(例如,使用scipy.ndimage.rotate
)用于绘图的基础数组,因为它始终会引入伪像,并且它们会影响我在图像中查看的内容。 对我来说,将像素旋转45度也更好。
我找到了这个 ,建议在图中使用scipy rotation方法。 但这对我不起作用。 这是相关代码:
im = plt.imshow(np.log2(data+1), origin='lower', interpolation='none', cmap=WhRd,
extent=[0, (end-start)*200000, 0, 50*200000])
im_rot = ndimage.rotate(im, 45)
这是错误,指向第二行:
/usr/local/lib/python2.7/dist-packages/scipy/ndimage/interpolation.pyc in rotate(input, angle, axes, reshape, output, order, mode, cval, prefilter)
631 axes[1] += rank
632 if axes[0] < 0 or axes[1] < 0 or axes[0] > rank or axes[1] > rank:
--> 633 raise RuntimeError('invalid rotation plane specified')
634 if axes[0] > axes[1]:
635 axes = axes[1], axes[0]
RuntimeError: invalid rotation plane specified
有什么方法可以实现我想要的吗?
两个建议:
也许将ndimage.rotate与插值配合使用会减少绘图中的伪影? 您可以选择适合您要求的插值方法。
也许这篇文章可能有帮助-它不使用ndimage。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.