需要在 X 轴标签的 SubPlots 之间添加空间,可能会删除轴槽口的标签 [英] Need to add space between SubPlots for X axis label, maybe remove labelling of axis notches

查看:28
本文介绍了需要在 X 轴标签的 SubPlots 之间添加空间,可能会删除轴槽口的标签的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

Looking to add in vertical space between plotted graphs to allow a X-Axis label to show:

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

Each graph needs to have space to show the day, currently the last 2 graphs are the only one's that show simply because the graphs are overlapping it.

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

Also curious if I could actually remove the notch labels for the X-Axis for the graphs above the one's marked Thursday/Friday, i.e. the bottom X-axis is the only one that shows. Same for the Y-Axis, but only the graphs on the left having the scale shown.

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

*Unfortunately I can't post an image to show this since I don't have enough rep.

代码片段:

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')
...

推荐答案

使用subplots_adjust.就您而言,这看起来不错:

Use subplots_adjust. In your case this looks good:

fig.subplots_adjust(hspace=.5)

要删除刻度标签,请执行以下操作:

to remove the tick labels do this:

ax1.set_xticklabels([])

类似于yticklabels.但是,您不能与具有刻度标签的图共享 x 轴.

Similar for the yticklabels. However, you cannot share the x-axis with the plots that do have tick labels.

这篇关于需要在 X 轴标签的 SubPlots 之间添加空间,可能会删除轴槽口的标签的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆