如何使用 pyplot 使 x 轴适应 audio/acoustics?

How to get an x-axis adapted to audio/acoustics with pyplot?

绘制频率响应曲线时:

import numpy as np
from scipy import signal
import matplotlib.pyplot as plt
w, h = signal.freqz([1, -1])
x = w * 44100 * 1.0 / (2 * np.pi)
y = 20 * np.log10(abs(h))

然后 plt.plot(x, y)plt.semilogx(x, y) 给出:

但其中 none 个有 "standard x-axis used in audio".

问题:音频应用中常用的x轴如何设置?包括:

以下是我的意思的几个例子:

你喜欢这个吗?

f, ax = plt.subplots(figsize=(12, 4))
ax.set(xscale="log")
plt.plot(x, y)
plt.grid(which="both", axis='both')
_ = plt.xticks([20,50,100,200,500,1000,2000,5000,10000,20000], 
               ["20", "50", "100", "200", "500", "1K", "2K", "5K", "10K", "20K"])