Python 如何在Matplotlibs中为对数比例轴线性间隔栅格?

Python 如何在Matplotlibs中为对数比例轴线性间隔栅格?,python,matplotlib,graphing,Python,Matplotlib,Graphing,在matplot lib中,我希望以线性间隔顺序隔开网格,而轴比例为对数 我想要的是: 而不是: 目前的准则是: ax.grid(True, which="major", ls="-") ax.set_yscale('log') ax.yaxis.set_major_formatter(StrMethodFormatter('{x:.8f}')) ax.yaxis.set_minor_formatter(StrMethodFormatter('{x:.

在matplot lib中,我希望以线性间隔顺序隔开网格,而轴比例为对数

我想要的是:

而不是:

目前的准则是:

ax.grid(True,  which="major", ls="-")
ax.set_yscale('log')
ax.yaxis.set_major_formatter(StrMethodFormatter('{x:.8f}'))
ax.yaxis.set_minor_formatter(StrMethodFormatter('{x:.8f}'))

可以在所需位置显式设置主刻度。简单的
ticks=[2**i代表范围内的i(30)]
或示例中更精细的ticks(这些将接近均匀分布,但不是完全分布)。或者,数字可以使用千分位显示。由对数刻度自动添加的小ticks看起来非常混乱,可以删除

从matplotlib导入pyplot作为plt
将numpy作为np导入
从matplotlib.ticker导入FixedLocator、StrMethodFormatter、NullFormatter、NullLocator
图,ax=plt.子批次()
ax.plot(np.exp(10+np.random.normal(0.01,0.61000).cumsum())
ax.grid(True,which=“major”,ls=“-”)
ax.set_yscale('log'))
刻度=[j*k代表j英寸(1100000000)代表k英寸[3,6,12]+[25*2**i代表范围(7)]]
ax.yaxis.set\u major\u定位器(固定定位器(刻度))
ax.yaxis.set_major_格式化程序(StrMethodFormatter('{x:,.0f}'))
ax.yaxis.set\u minor\u定位器(NullLocator())
#ax.yaxis.set\u minor\u格式化程序(NullFormatter())
ax.set_ylim(ymin=2)
plt.紧_布局()
plt.show()

谢谢。你是如何推导出滴答声的逻辑的?只是尝试一些公式,然后摆弄直到找到与示例类似的东西。