希望在绘制的图形之间添加垂直空间以允许 X 轴标签显示:

每个图形都需要有空间来显示日期,目前只有最后 2 个图形显示,因为图形重叠了它。

也很好奇我是否真的可以删除标记为星期四/星期五的图形上方 X 轴的凹口标签,即底部 X 轴是唯一显示的。 Y 轴相同,但只有左侧的图形显示了比例。

*不幸的是,由于我没有足够的代表,我无法发布图片来展示这一点。

代码片段:

import mathlib.pyplot as pyplot
fig = pyplot.figure()
ax1 = fig.add_subplot(4,2,1)
ax1.set_yscale('log')
ax2 = fig.add_subplot(4,2,2, sharex=ax1, sharey=ax1)
ax3 = fig.add_subplot(4,2,3, sharex=ax2, sharey=ax2)
ax4 = fig.add_subplot(4,2,4, sharex=ax3, sharey=ax3)
ax5 = fig.add_subplot(4,2,5, sharex=ax4, sharey=ax4)
ax6 = fig.add_subplot(4,2,6, sharex=ax5, sharey=ax5)
ax7 = fig.add_subplot(4,2,7, sharex=ax6, sharey=ax6)
ax1.plot(no_dict["Saturday"],'k.-',label='Saturday')
ax1.set_xlabel('Saturday')
ax1.axis([0,24,0,10000])
pyplot.suptitle('Title')
pyplot.xlabel('Hour in 24 Hour Format')
ax2.plot(no_dict["Sunday"],'b.-',label='Sunday')
ax2.set_xlabel('Sunday')
...

python - 需要在 X 轴标签的 SubPlots 之间添加空间,可能会删除轴槽口的标签-LMLPHP

最佳答案

使用 subplots_adjust 。在您的情况下,这看起来不错:

fig.subplots_adjust(hspace=.5)

要删除刻度标签,请执行以下操作:
ax1.set_xticklabels([])
yticklabels 类似。但是,您不能与具有刻度标签的图共享 x 轴。

python - 需要在 X 轴标签的 SubPlots 之间添加空间,可能会删除轴槽口的标签-LMLPHP

关于python - 需要在 X 轴标签的 SubPlots 之间添加空间,可能会删除轴槽口的标签,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/5159065/

10-15 23:32
查看更多