如何使用 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轴如何设置?包括:
- 某种对数轴,但不确定:它真的是正常的对数轴(见后面的例子)吗?
- 轴从 20 到 20Khz,并滴答
["20", "50", "100", "200", "500", "1K", "2K", "5K", "10K", "20K"]
以下是我的意思的几个例子:
你喜欢这个吗?
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"])
绘制频率响应曲线时:
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轴如何设置?包括:
- 某种对数轴,但不确定:它真的是正常的对数轴(见后面的例子)吗?
- 轴从 20 到 20Khz,并滴答
["20", "50", "100", "200", "500", "1K", "2K", "5K", "10K", "20K"]
以下是我的意思的几个例子:
你喜欢这个吗?
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"])