Pyplot - 如何将标签设置为在同一子图中绘制的多个数据

时间:2016-01-19 18:08:50

标签: python matplotlib subplot

我有一个包含多个数据类的数据集。它们的组织方式如下:[频道,样本,任务]。有5个通道,每个通道每个通道1024个样本,有270个任务。我想要5个情节。每个频道一个。我想标记每个频道中的每个任务。我只是有颜色来及时识别每个任务。但颜色与任务无关。

RewriteCond %{QUERY_STRING} ^$
RewriteRule ^/$ /index.php [L]

This is what I have by now

1 个答案:

答案 0 :(得分:0)

for trial in range(12):
  x = np.linspace(0, (tam_janela + tam_janela*trial), (tam_janela + tam_janela*trial) )

  if labels[trial] == 1:
    task_label = 'Left Hand'
  elif labels[trial] == 2:
    task_label = 'Right Hand'
  elif labels[trial] == 3:
    task_label = 'Both feet'

  lab, = ch1.plot((x[(trial*1024):]), eegdata[0, :, trial], label = 'Inline label')
  ch1.set_ylabel('Channel 1')
  lab.set_label(task_label)

  ch2.plot((x[(trial*1024):]), eegdata[1, :, trial])
  ch2.set_ylabel('Channel 2')

  ch3.plot((x[(trial*1024):]), eegdata[2, :, trial])
  ch3.set_ylabel('Channel 3')

  ch4.plot((x[(trial*1024):]), eegdata[3, :, trial])
  ch4.set_ylabel('Channel 4')

  ch5.plot((x[(trial*1024):]), eegdata[4, :, trial])
  ch5.set_xlabel('Time')
  ch5.set_ylabel('Channel 5')

ch1.legend(loc='center left', fontsize = 7, ncol = 12)
plt.suptitle('EEG recordings from Subject A with 5 channels (V)')

plt.grid(True)
plt.show()

The result I wanted