Matplotlib-向下移动X轴标签,但不向下移动X轴刻度 [英] Matplotlib - Move X-Axis label downwards, but not X-Axis Ticks

查看:566
本文介绍了Matplotlib-向下移动X轴标签,但不向下移动X轴刻度的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Matplotlib绘制直方图. 使用上一个问题的提示: Matplotlib-为每个垃圾箱贴标签, 我或多或少地努力了.

I'm using Matplotlib to plot a histogram. Using tips from my previous question: Matplotlib - label each bin, I've more or less go the kinks worked out.

最后一个问题-以前-在x轴刻度线(0.00、0.04、0.08、0.12等)下方显示了x轴标签(时间(以毫秒为单位)")

There's one final issue - previously - the x-axis label ("Time (in milliseconds)") was being rendered underneath the x-axis tickmarks (0.00, 0.04, 0.08, 0.12 etc.)

根据乔·金斯顿(Joe Kingston)的建议(请参阅上面的问题),我尝试使用:

Using the advice from Joe Kingston (see question above), I tried using:

ax.tick_params(axis='x', pad=30)

但是,这会同时移动x轴刻度线(0.00、0.04、0.08、0.12等)以及x轴标签(时间(以毫秒为单位)"):

However, this moves both the x-axis tickmarks (0.00, 0.04, 0.08, 0.12 etc.), as well as the x-axis label ("Time (in milliseconds)"):

有什么办法只能将x轴标签移动到三行图形的下面吗?

Is there any way to move only the x-axis label to underneath the three rows of figures?

Nb:您可能需要直接打开下面的PNG-右键单击图像,然后单击查看图像"(以FF键)或在新标签页中打开图像"(Chrome).由SO完成的图像调整大小使它们几乎不可读

推荐答案

使用labelpad参数:

use labelpad parameter:

pl.xlabel("...", labelpad=20)

或在之后设置:

ax.xaxis.labelpad = 20

这篇关于Matplotlib-向下移动X轴标签,但不向下移动X轴刻度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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