My data are :
import matplotlib.pyplot as plt
from datetime import *
import matplotlib
my_vectors =[['120819152800063',10,189, 8],
['120819152800063', 10,184, 8],
['120819152800063', 0,190, 43],
['120819152800067', 8,67, 10],
['120819152800067', 8,45, 10],
['120819152800073', 10,31, 8],
['120819152800073', 10,79, 8],
['120819152800073', 7,102, 25],
['120819152800075', 125,0, 13]]
I'm trying to plot vectors to represent the data, but i cheated(i represent a line which represent the body of the vector and 2 points for the beginning and the end), I just want to color the body of each 'vector'.
timeString = zip(*my_vectors)[0]
timeDatetime=[datetime.strptime(aTime, '%y%m%d%H%M%S%f') for aTime in timeString]
timeDate=matplotlib.dates.date2num(timeDatetime)
# Represent the data time
X = tuple([int(x) for x in timeString])
# Represent the data sender
Y = zip(*my_vectors)[1]
# represent the data type
U = zip(*my_vectors)[2]
# represent the data receiver
V = zip(*my_vectors)[3]
# the 'body' of the vectors
plt.vlines(timeDate,Y,V,colors='r')
# the beginning of the vectors
plt.plot_date(timeDate,Y,'b.',xdate=True)
# the end of the vectors
plt.plot_date(timeDate,V,'y.')
plt.show()
To have a better read of my data, i need to change color for each data type but i don't know how many data type i'll have. How can i do this?
I have read this question but i don't really understand the answer :
Setting different color for each series in scatter plot on matplotlib