python – matplotlib.pyplot.imshow:在使用属性“sharex”和“sharey”时删除图
发布时间:2021-02-20 19:45:09 所属栏目:Python 来源:互联网
导读:我有一个类似于一个发布的 here的问题.不同的是,当我绘制通过sharex和sharey属性共享轴的两个子图时,我会在绘图区域内得到不需要的空格.即使设置自动调整(False)后,空格仍然会持续.例如,使用与上述帖子的答案相似的代码: import matplotlib.pyplot as pltimp
我有一个类似于一个发布的 here的问题.不同的是,当我绘制通过sharex和sharey属性共享轴的两个子图时,我会在绘图区域内得到不需要的空格.即使设置自动调整(False)后,空格仍然会持续.例如,使用与上述帖子的答案相似的代码: import matplotlib.pyplot as plt import numpy as np fig = plt.figure() ax = fig.add_subplot(2,1,1) ax.imshow(np.random.random((10,10))) ax.autoscale(False) ax2 = fig.add_subplot(2,2,sharex=ax,sharey=ax) # adding sharex and sharey ax2.imshow(np.random.random((10,10))) ax2.autoscale(False) plt.show() 导致this图像. 我也按照建议here尝试了ax.set_xlim(0,10)和ax.set_xbound(0,10),但是没有效果.如何摆脱额外的白色空间?任何想法将不胜感激. 解决方法如建议 here,补充说:ax.set_adjustable('box-forced') ax2.set_adjustable('box-forced') 解决问题. (documentation) (编辑:鲜蔬坊站长网) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
相关内容
- 高效率地保存多个 Python 对象!你学会了吗?
- python – Numpy.dot()维度未对齐
- python – django auth用户截断电子邮件字段
- 如何使用Python的ctypes和readinto读取包含数组的结构?
- python – Bokeh中设置的静态路径变量在哪里(对于create_ht
- python – Ipdb和方法文档
- pyDes 实现 Python 版的 DES 对称加密/解密--转
- ValueError:参数必须是密集张量–Python和TensorFlow
- python – OPENCV:Calibratecamera 2重投影错误和自定义计
- python – LinkExtractor和SgmlLinkExtractor之间的区别
推荐文章
站长推荐
热点阅读