我需要生成一个列表,其中包含10 ^ a和10 ^ b之间的对数刻度滴答,并且
# List containing 0.1, 0.2, 0.3, ..., 800, 900, 1000
x = np.arange(0.1, 1.0, 0.1).tolist() +
np.arange(1, 10, 1).tolist() +
np.arange(10, 100, 10).tolist() +
np.arange(100, 1000, 100).tolist()
有没有一种方法可以做到这一点?
可以用broadcasting
-
broadcasting
如果您只想对数刻度刻度,则可以使用N = 4 # number of "levels"
out = ((10**np.arange(N)[:,None])*np.arange(0.1, 1.0, 0.1)).ravel()
:
matplotlib
输出:
x = np.arange(100)
y = x**2
plt.plot(x,y)
plt.xscale('log')