Chr*_*vre 38 python matplotlib
希望在绘制的图形之间添加垂直空间以允许X轴标签显示:
每个图形都需要有空间来显示当天,目前最后两个图形是唯一显示的图形,因为图形与它重叠.
同样好奇的是,我是否真的可以删除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')
...
Run Code Online (Sandbox Code Playgroud)
Pau*_*aul 83
使用subplots_adjust.在你的情况下,这看起来很好:
fig.subplots_adjust(hspace=.5)
Run Code Online (Sandbox Code Playgroud)
要删除刻度标签,请执行以下操作:
ax1.set_xticklabels([])
Run Code Online (Sandbox Code Playgroud)
类似的yticklabels
.但是,您不能与具有刻度标签的图表共享x轴.
归档时间: |
|
查看次数: |
56131 次 |
最近记录: |