Я пытаюсь создать простой график, который читает значения x, y, хранящиеся в файлах, и отображает их с использованием разного цвета для каждой строки.Ниже моя попытка.
## to run ctrl+shift+b
#print("hello world")
import csv
import itertools
import pylab
import numpy as np
import matplotlib.pyplot as plt
f = open('2016-09-09-22_25_A_initial-Hysteresis.txt', 'r')
f2 = open('2016-09-09-22_25_F_initial-Hysteresis.txt', 'r')
f3 = open('2016-09-09-22_25_K_initial-Hysteresis.txt', 'r')
f4 = open('2016-09-09-22_25_P_initial-Hysteresis.txt', 'r')
f5 = open('2016-09-09-22_25_U_initial-Hysteresis.txt', 'r')
f6 = open('2016-09-09-22_26_A_initial-Hysteresis.txt', 'r')
f7 = open('2016-09-09-22_26_F_initial-Hysteresis.txt', 'r')
f8 = open('2016-09-09-22_26_K_initial-Hysteresis.txt', 'r')
f9 = open('2016-09-09-22_26_P_initial-Hysteresis.txt', 'r')
f10 = open('2016-09-09-22_26_U_initial-Hysteresis.txt', 'r')
x = f.readlines()
x2 = f2.readlines()
x3 = f3.readlines()
x4 = f4.readlines()
x5 = f5.readlines()
x6 = f6.readlines()
x7 = f7.readlines()
x8 = f8.readlines()
x9 = f9.readlines()
x10 = f10.readlines()
vars = [x, x2, x3, x4, x5, x6, x7, x8, x9, x10]
colors = ['b', 'r', 'g', 'c']
cc = itertools.cycle(colors)
datatable = []
i = 0
for content in vars:
for line_num, line_content in enumerate(content):
data = line_content.split()
row = [[], [], [], []]
for index, num in enumerate(data, start = 0):
isappendable = False
try:
data_attempt = float(num)
index = int(index)
row[index] = data_attempt
if(line_num > 15):
isappendable = True
except ValueError:
data_attempt = 0
if(isappendable):
datatable.append(row)
i = i + 1
c = next(cc)
index = []
input = []
output = []
for n,x in enumerate(datatable):
input.append(x[0])
output.append(x[1])
num_str = str(i)
name = "DUT" + num_str
plt.plot(input, output, label = name)
plt.legend(loc='upper left')
plt.show()
Когда я выполняю код, я получаю следующее изображение. 
Это выглядит довольно близко к тому, что я хочу (там10 линий, которые значительно перекрывают друг друга), но у меня проблема в том, что цвета в легенде, кажется, не совпадают с цветами на графике.Легенда показывает цвета, которые я хотел бы, чтобы графики были, но линии все одинаковые (даже когда я увеличиваю их).Как бы я это исправить?Спасибо