我正在尝试从多电极数据集绘制许多信号(196)(https://zenodo.org/records/1411883)。我想绘制一些很酷的东西来一起查看所有寄存器。我想要得到类似的东西:
有没有任何 python 包或方法可以建议我遵循来绘制所有这些信息?
我尝试创建子图,但它们太小并且需要太多时间才能生成。
我认为在同一个绘图上绘制 196 个信号有点太多了。
下面是 30 个信号,使用计算的偏移量:
import matplotlib.pyplot as plt
import numpy as np
def multisignals(t, signals, ax=None):
if ax is None:
fig, ax = plt.subplots()
# Center the signals and add offsets
sigs = signals - signals.mean(axis=1, keepdims=True)
offset = np.max(sigs.max(axis=1)[:-1] - sigs.min(axis=1)[1:])
# Plot the signals
ax.plot(t, sigs.T + np.arange(len(signals)) * offset)
# Plots horizontal lines to separate the signals
for i in range(len(signals) + 1):
ax.axhline(i * offset - offset / 2, color="k", lw=0.5, alpha=0.3)
return ax
def create_signals(t, n):
# Dummy function to generate signals
freqs = np.random.rand(n) * 3 + 1
amps = np.random.rand(n) * 3.8 + 0.2
signals = np.zeros((n, len(t)))
for i, (freq, amp) in enumerate(zip(freqs, amps)):
signals[i] = amp * np.sin(2 * np.pi * freq * t)
return signals
def main():
t = np.linspace(0, 10, 600)
n = 30
signals = create_signals(t, n) + create_signals(t, n) + create_signals(t, n)
ax = multisignals(t, signals)
ax.tick_params(left=False, labelleft=False)
plt.show()
if __name__ == "__main__":
main()