为什么地块不显示?

时间:2019-08-02 12:22:26

标签: matplotlib imshow

为什么plt.imshow()不显示图像? 请帮忙,我不明白为什么不显示情节 我使用的是python 2.7,没有错误,但ptl不起作用

nb_samples = 5
start_label = 0
max_freq = 30
nb_labels = 2 #len(good_labels)
labels = good_labels[start_label:start_label+nb_labels]
colors = ['b', 'r', 'g'] 
for k in range(nb_labels):
  l = labels[k]
  c = colors[k]
  plt.figure(figsize=(20,5))

  freqs_list = []
  for i in range(nb_samples):
      data = df[df.label==l].iloc[i,1:].values

      freqs, m2, m3 = mlab.specgram(data, NFFT=128, noverlap=64)
      freqs_list.append(freqs.tolist())

      plt.subplot(1,nb_samples+1,i+1)
      plt.plot(data, color=c)
      plt.ylabel('label %s' % l)

  mean_freqs = np.mean(np.array(freqs_list), axis=0)
  assert freqs.shape == mean_freqs.shape
  plt.subplot(1,nb_samples+1,nb_samples+1)
  plt.imshow(mean_freqs[:max_freq,:], interpolation='nearest')
  plt.title('Label %s \n(average spectrogram)' % l)

  plt.tight_layout()`

0 个答案:

没有答案