在所有日志日志子图中设置次要刻度

我有一个具有两个对数对数刻度的图形。我也想绘制较小的滴答声。即使我使用了不同于Stack Overflow的解决方案,我的身材也不像我想要的那样。

我修改过的解决方案之一来自ImportanceOfBeingErnest,代码如下:

fig,((ax1,ax2)) = plt.subplots(1,2,figsize=(8,5),sharey=True)

# First plot
ax1.loglog(PLOT1['X'],PLOT1['Y'],'o',markerfacecolor='red',markeredgecolor='red',markeredgewidth=1,markersize=1.5,alpha=0.2)

ax1.set(xlim=(1e-4,1e4),ylim=(1e-8,1e2))
ax1.set_xscale("log"); ax1.set_yscale("log")
ax1.xaxis.set_major_locator(matplotlib.ticker.LogLocator(base=10.0,numticks=25))
ax1.yaxis.set_major_locator(matplotlib.ticker.LogLocator(base=10.0,numticks=25))

locmaj = matplotlib.ticker.LogLocator(base=10,numticks=25) 
ax1.xaxis.set_major_locator(locmaj)
locmin = matplotlib.ticker.LogLocator(base=10.0,subs=(0.2,0.4,0.6,0.8),numticks=25)
ax1.xaxis.set_minor_locator(locmin)
ax1.xaxis.set_minor_formatter(matplotlib.ticker.NullFormatter())

locmaj = matplotlib.ticker.LogLocator(base=10,numticks=25) 
ax1.yaxis.set_major_locator(locmaj)
locmin = matplotlib.ticker.LogLocator(base=10.0,numticks=25)
ax1.yaxis.set_minor_locator(locmin)
ax1.yaxis.set_minor_formatter(matplotlib.ticker.NullFormatter())

ax1.set_xlabel('X values',fontsize=10,fontweight='bold')
ax1.set_ylabel('Y values',fontweight='bold')

# Plot 2
ax2.loglog(PLOT2['X'],PLOT2['Y'],markerfacecolor='blue',markeredgecolor='blue',alpha=0.2)

ax2.set(xlim=(1e-4,1e2))
ax2.xaxis.set_major_locator(matplotlib.ticker.LogLocator(base=10.0,numticks=25))
ax2.yaxis.set_major_locator(matplotlib.ticker.LogLocator(base=10.0,numticks=25) 
ax2.xaxis.set_major_locator(locmaj)
ax2.yaxis.set_major_locator(locmaj)

locmin = matplotlib.ticker.LogLocator(base=10.0,numticks=25)
ax2.xaxis.set_minor_locator(locmin)
ax2.yaxis.set_minor_locator(locmin)

ax2.xaxis.set_minor_formatter(matplotlib.ticker.NullFormatter())
ax2.yaxis.set_minor_formatter(matplotlib.ticker.NullFormatter())

ax2.set_xlabel('X values',fontweight='bold')
ax2.set_ylabel('Y values',fontweight='bold')
ax2.minorticks_on()

plt.show()

我得到的情节如下。如您所见,次刻度仅出现在ax1的x轴上。

在所有日志日志子图中设置次要刻度

如何在两个子图和两个轴(x和y)中设置次刻度?

非常感谢您。

hheyong 回答:在所有日志日志子图中设置次要刻度

暂时没有好的解决方案,如果你有好的解决方案,请发邮件至:iooj@foxmail.com
本文链接:https://www.f2er.com/2960434.html

大家都在问