1
我imshow
子图上的Y限制被卡在看似任意的范围内。使用带有matplotlib的共享x轴的imshow
在这个例子中,我试图展示N次试验的平均值,然后随着时间的推移将所有N次试验绘制成2d图。
import numpy as np
import matplotlib.pyplot as plt
np.random.seed(42)
N = 20 # number of trials
M = 3000 # number of samples in each trial
data = np.random.randn(N, M)
x = np.linspace(0,1,M) # the M samples occur in the range 0-1
# ie the sampling rate is 3000 samples per second
f, (ax1, ax2) = plt.subplots(2,1, sharex=True)
ax1.plot(x, np.mean(data, 0))
ax2.imshow(data, cmap="inferno", interpolation="nearest", extent=[0, 1, 0, N])
ax2.set_ylim(0, N)
ax1.set_ylabel("mean over trials")
ax2.set_ylabel("trial")
ax2.set_xlabel("time")
有没有什么技巧,正确设定Y限制?
你可以指定你正在努力实现与第二个图(如详细的使用程度,为什么你绘制的数据,而不是数据什么.T等)? –
@ P.Camilleri增加了一些激发人心的问题。 –
@ P.Camilleri也为情节添加了标签。 –