如何在Matplotlib中禁用对数图的次要滴答声? [英] How to disable the minor ticks of log-plot in Matplotlib?
本文介绍了如何在Matplotlib中禁用对数图的次要滴答声?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
这是一个简单的情节:
1)如何禁用刻度线? 2)如何减少他们的人数?
1) How to disable the ticks? 2) How to reduce their number?
这是示例代码:
from pylab import *
import numpy as np
x = [5e-05, 5e-06, 5e-07, 5e-08, 5e-09, 5e-10]
y = [-13, 14, 100, 120, 105, 93]
def myfunc(x,p):
sl,yt,yb,ec=p
y = yb + (yt-yb)/(1+np.power(10, sl*(np.log10(x)-np.log10(ec))))
return y
xp = np.power(10, np.linspace(np.log10(min(x)/10), np.log10(max(x)*10), 100))
pxp=myfunc(xp, [1,100,0,1e-6])
subplot(111,axisbg="#dfdfdf")
plt.plot(x, y, '.', xp, pxp, 'g-', linewidth=1)
plt.xscale('log')
plt.grid(True,ls="-", linewidth=0.4, color="#ffffff", alpha=0.5)
plt.draw()
plt.show()
哪个生产:
推荐答案
plt.minorticks_off()
将其关闭!
要更改它们的数量/放置它们的位置,可以使用subsx
参数.像这样:
To change the number of them/position them, you can use the subsx
parameter. like this:
plt.xscale('log', subsx=[2, 3, 4, 5, 6, 7, 8, 9])
从文档:
subsx/subsy:在每个主要刻度之间放置子刻度的位置. 应该是整数序列.例如,以log10的比例尺:[2, 3,4,5,6,7,8,9]
subsx/subsy: Where to place the subticks between each major tick. Should be a sequence of integers. For example, in a log10 scale: [2, 3, 4, 5, 6, 7, 8, 9]
将在每个主要音调之间放置8个对数间隔的次要刻度线 勾选.
will place 8 logarithmically spaced minor ticks between each major tick.
这篇关于如何在Matplotlib中禁用对数图的次要滴答声?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文