需要在 X 轴标签的子图之间添加空间,也许删除轴凹口的标签
希望在绘制的图表之间添加垂直空间以允许显示 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')
...
Looking to add in vertical space between plotted graphs to allow a X-Axis label to show:
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.
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.
Code snippet:
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')
...
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
使用 subplots_adjust。在您的情况下,这看起来不错:
要删除刻度标签,请执行以下操作:
与
yticklabels
类似。但是,您不能与具有刻度标签的图共享 x 轴。Use subplots_adjust. In your case this looks good:
to remove the tick labels do this:
Similar for the
yticklabels
. However, you cannot share the x-axis with the plots that do have tick labels.方法调整该子图的轴位置:
要更改某个子图周围的间距(而不是全部子图),您可以使用以下 0,子图向下移动。如果
偏移量> 0
,子图向上移动。请注意,如果偏移量太大以至于子图的新位置与另一个子图重叠,则子图将会消失。
To change the spacing around a certain subplot, instead of all of them, you can adjust the position of the axes of that subplot using:
If
offset < 0
, the subplot is moved down. Ifoffset > 0
, the subplot is moved up.Note that the subplot will disappear if offset is so big that the new position of the subplot overlaps with another subplot.