【发布时间】:2019-09-30 19:01:09
【问题描述】:
我正在尝试用我的数据绘制直方图。 在 Jupyter notebook 上使用 python
viz = cdf[['GyrNative', 'GyMutant', 'Hbond_native', 'HMutant', 'RMSDNative','RMSDMutant', 'RMSFNative', 'RMSFMutant', 'SASANative', 'SASAMutant']]
plt.figure(figsize = (15,10))
viz.hist(grid=True, rwidth = 0.9, color ='red')
plt.tight_layout(pad=0.4, w_pad=0.5, h_pad=0.1)
plt.show()
生成的图真的很小...如何一次增加每个图的大小?
【问题讨论】:
-
如果您的意思是更改单个图的大小,您应该查看
GridSpec文档以及如何使用add_subplot()方法创建图的子图。 -
@Berenger 我尝试使用,这不是根据 GridSpec 文档,但是这个绘图只有一个图表其余部分是空白的。有什么具体原因吗?
viz = cdf[['GyrNative', 'GyMutant', 'Hbond_native', 'HMutant', 'RMSDNative','RMSDMutant', 'RMSFNative', 'RMSFMutant', 'SASANative', 'SASAMutant']] viz.hist(grid=True, rwidth = 0.9, color ='red', ncols=4, nrows=3, constrained_layout=True) plt.tight_layout(pad=0.4, w_pad=0.5, h_pad=0.1) -
嗨@Kay,你能为
viz添加一些示例数据吗? -
+-------+---------+---------+-------+-------+---------+---------+ | Col1e | Col2t | Col3e | Col4t | Col5e | Col6t | +-------+---------+---------+-------+-------+---------+---------+ | 0 | 1.51818 | 1.50145 | 128.0 | 141 | 100.228 | 98.491 | | 1 | 1.51722 | 1.54022 | 126.0 | 130 | 99.562 | 99.428 | | 2 | 1.51961 | 1.53201 | 139.0 | 139 | 100.269 | 99.956 | | 3 | 1.51981 | 1.54077 | 137.0 | 123 | 100.230 | 100.788 | | 4 | 1.52274 | 1.53873 | 127.0 | 126 | 98.788 | 101.350 | +-------+---------+---------+-------+-------+---------+---------+ -
谢谢。我为您添加了一个潜在的解决方案。重要的是要记住调用项目的顺序以及 `.hist' 调用的具体作用。
标签: python-3.x histogram