繁体   English   中英

在matplotlib中旋转图像?

[英]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

有什么方法可以实现我想要的吗?

两个建议:

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM