matplotlib inset_axis插入位置的刻度标签与父轴重叠 [英] matplotlib inset_axis inset placement has tick labels overlapping parent axes

查看:57
本文介绍了matplotlib inset_axis插入位置的刻度标签与父轴重叠的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我使用 inset_axes 在图形中放置插图时,对于小图形尺寸,插图的刻度标签将与轴框架重叠.有没有办法通过调整图形来避免这个问题?

When I use inset_axes to place an inset in a figure, for small figure sizes, the tick labels for the inset will overlap the axes frame. Is there a way to make the figure adjust to avoid this problem?

代码:

fig, ax1 = plt.subplots()

ax1.plot(dd1["mag"].index, dd1["mag"], '.-',label="$\omega$")
ax1.plot(newindex,curvy1,'--', label="${0:.3f} \cdot I$".format(popt1[0]))
ax1.set_xlim((5e11, 5e13))
ax1.set_ylim((2e-7,.25e-4))

ax1_inset = inset_axes(ax1, width="40%", height="40%", loc=4)
ax1_inset.plot(dd1["mag"].index, (one - np.array(dd1["mag"]))/one)
ax1_inset.plot(dd1["mag"].index, map(lambda x: -.01, dd1["mag"].index), ':')
ax1_inset.set_xlim(5e11,5e13)
ax1_inset.set_ylim(-.1,.05)
ax1_inset.set_xscale("log")

具有matplotlibrc值:

with the matplotlibrc values:

matplotlib.rcParams['figure.figsize'] = '4,3'

matplotlib.rcParams['axes.formatter.use_mathtext'] = 'True'
matplotlib.rcParams['axes.formatter.useoffset'] = 'False'

matplotlib.rcParams['figure.subplot.left'] = .22
matplotlib.rcParams['figure.subplot.right'] = .95
matplotlib.rcParams['figure.subplot.bottom'] = .20
matplotlib.rcParams['figure.subplot.top'] = .90

推荐答案

kwarg"borderpad"似乎可以解决此问题.

The kwarg "borderpad" appears to solve this problem.

这篇关于matplotlib inset_axis插入位置的刻度标签与父轴重叠的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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