如何在Matplotlib中更改刻度标签和轴标签之间的分隔 [英] How to change separation between tick labels and axis labels in Matplotlib

查看:84
本文介绍了如何在Matplotlib中更改刻度标签和轴标签之间的分隔的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我使用Matplotlib时,我的轴标签经常看起来不好(太靠近刻度标签).

My axis labels often look not good (too close to tick labels) when I use Matplotlib.

如何设置刻度标签和轴标签之间的距离?我只需要扩大星数"标签和相应的刻度标签之间的距离即可.也许乳胶 \ vspace {} 正在工作,但我不知道如何实现. fig.subplots_adjust(left =)不是解决方案.

How to set distance between tick labels and axis label? I just need to enlarge distance between "Number of stars" label and corresponding tick labels. Maybe latex \vspace{} is working but I don't know how to implement it. fig.subplots_adjust(left=) is not a solution.

推荐答案

要使轴标签远离轴,可以在所使用的相应方法的可选 labelpad 参数中包含一个参数.设置标签,即 ax.set_ylabel() ax.set_xlabel() .此参数采用标量,该标量是轴与 points 中给出的标签之间的间距.

To move the axis label further away from the axis, you can include an argument to the optional labelpad parameter of the corresponding method used to set the label, i.e. ax.set_ylabel() or ax.set_xlabel(). This parameter takes a scalar which is the spacing between the axis and the label given in points.

为使用 底图的drawparallels() 方法,我相信您可以在参数 xoffset yoffset 中加入参数,取决于要更改文本位置的轴.这些参数的参数具有地图宽度的单位",例如 xoffset = 0.05 使x-ticks的偏移量为地图宽度的5%.

As to achieve the same effect when using the drawparallels() method of Basemap, I believe you can include an argument to the parameters xoffset or yoffset, depending on which axis you want to alter the placement of the text. The arguments of these parameters have "units" of map width, meaning e.g. xoffset=0.05 makes the offset of the x-ticks 5 % of the map width.

这篇关于如何在Matplotlib中更改刻度标签和轴标签之间的分隔的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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