简体   繁体   English

插入图中的重叠刻度线matplotlib

[英]Overlapping tick marks in inset plot matplotlib

In an older version of Matplotlib (with WinPython 3.4.2.3), if I wanted to include a subplot as an inset, it hid the tickmarks below it: http://imgur.com/GsKtCUA,KoQGek6#1 在较旧版本的Matplotlib(带有WinPython 3.4.2.3)中,如果我想包含一个子图作为插图,它会隐藏下面的刻度线: http ://imgur.com/GsKtCUA,KoQGek6#1

In an upgraded version (with Winpython 3.4.3.2), it overlays both of the axis tick marks: http://imgur.com/GsKtCUA,KoQGek6#0 在升级版本(使用Winpython 3.4.3.2)中,它覆盖了两个轴刻度线: http : //imgur.com/GsKtCUA,KoQGek6#0

How do I revert to the old behavior, where the bottom plot's ticks are hidden? 我该如何恢复到原来的行为,即隐藏了底部图的刻度?

Thanks! 谢谢!

Here is an overview of my plotting code: 这是我的绘图代码的概述:

fig=plt.figure(8, figsize=(8,7), dpi=300)

ax1 = fig.add_axes([0.1, 0.1, 0.8, 0.8], xscale='log', xlim=(5e-8, 1e-4), xlabel='...', ylabel='...',ylim=(-0.3,9)) # main axes
ax2 = fig.add_axes([0.52, .52, .38,.38], xscale='log', xlim=(5e-8, 1e-4), xlabel='...', ylabel='...') # inset axes

# main figure
ax1.plot(...)

# insert
ax2.plot(...)

xticks = ax2.xaxis.get_major_ticks()
print(xticks)
xticks[5].label1.set_visible(False)
#xticks[-2].label1.set_visible(False)

yticks = ax2.yaxis.get_major_ticks()
print(yticks)
yticks[-1].label1.set_visible(False)


#start3, end3 = ax2.get_ylim()
ax2.yaxis.set_ticks([0,5,10])

如果我在ax2.plot()中使用关键字axisbg ='white',它将按预期工作。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM