【发布时间】:2019-01-13 23:28:43
【问题描述】:
我希望水平调整子图之间的空间。特别是在每第二行之间。我可以使用fig.subplots_adjust(hspace=n) 调整每一行。但是是否可以将其应用于每 2 行?
import matplotlib.pyplot as plt
fig, ax = plt.subplots(figsize = (10,10))
plt.style.use('ggplot')
ax.grid(False)
ax1 = plt.subplot2grid((5,2), (0, 0))
ax2 = plt.subplot2grid((5,2), (0, 1))
ax3 = plt.subplot2grid((5,2), (1, 0))
ax4 = plt.subplot2grid((5,2), (1, 1))
ax5 = plt.subplot2grid((5,2), (2, 0))
ax6 = plt.subplot2grid((5,2), (2, 1))
ax7 = plt.subplot2grid((5,2), (3, 0))
ax8 = plt.subplot2grid((5,2), (3, 1))
fig.subplots_adjust(hspace=0.9)
【问题讨论】:
-
fig, ax = plt.subplots(figsize = (30,30))改变figsize,就是改变你的身材大小。 -
我在 jupyter notebook 中运行相同的代码,但我只是更改了 figsize 并且效果很好。关于
hspace,从官方文档来看,hspace 的目标是按行调整空间,以具有相同的功能,但在每第二行中,您必须根据我的知识寻求定制的东西。 -
我恢复了编辑,否则它变成了一个完全不同的问题。
标签: python matplotlib plot subplot