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

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

问题描述

我正在使用 Matplotlib 绘制直方图.使用我上一个问题中的提示:Matplotlib - 标记每个 bin,我或多或少已经解决了问题.

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 轴标签(时间(以毫秒为单位)")在 x 轴刻度线(0.00、0.04、0.08、0.12 等)下方呈现

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?

注意:您可能需要直接打开下面的 PNG - 右键单击​​图像,然后查看图像(在 FF 中),或在新选项卡中打开图像(Chrome).SO 完成的图像大小调整使它们几乎无法读取

推荐答案

使用labelpad参数:

use labelpad parameter:

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

或设置在:

ax.xaxis.labelpad = 20

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

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