我想在这个图的 x 轴上有更多的刻度(例如 20hz、40hz、80hz、160hz、320hz、640hz 等的刻度):
您是否知道如何调整此代码:?
from numpy import cos, sin, pi, absolute, arange, log10, linspace
from pylab import figure, clf, plot, xlabel, ylabel, xlim, ylim, title, grid, axes, show, semilogx
f=linspace(20,20000, num=100)
ampl=linspace(-5,1, num=100)
semilogx(f, ampl, linewidth=2)
xlabel('Frequency (Hz)')
ylabel('Gain (dB)')
title('Frequency Response')
xlim(20, 20000)
ylim(-150, 10)
grid(True)
show()
PS:由于给出的答案,这是解决方案:
t=[1,2,4,8,16,32,64,128,256,512,1024]`
t1= [x*20 for x in t]
xticks(t1,t1)