python - Adding multiple lines of different colors in matplotlib -
i trying plot multiple lines in single figure, , want each line of unique color, came know matplotlib default. in case isn't working. same color each of lines in figure.
from sklearn import datasets import pandas pd import numpy np import random import matplotlib.pyplot plt # loading boston dataset sklearn , creating dataframe boston = datasets.load_boston() data = pd.dataframe(boston.data, columns = boston.feature_names) #for dropping multiple column datadrop = data.drop(['crim','dis', 'zn', 'indus','chas','nox', 'rad', 'tax','lstat', 'b', 'ptratio', 'rm'], axis=1) #converting numpy array m = 20 dataarray = datadrop['age'].values absmean = dataarray.mean() k in range(0,10): n = len(datadrop.index) p = random.random() c = int(n*p) #uniform sampling of c elements above mean = 0 values = np.empty([1, 2]) in range(0,m): mean = ( mean*i + np.random.choice(dataarray, c).mean() ) / (i+1) print mean, tuple = np.array([mean, i]) values = np.vstack([values,tuple]) print values plt.plot(values[1:,1], values[1:,0]) plt.axhline(absmean, color = 'red') plt.show()
see https://matplotlib.org/users/colors.html. example:
plt.plot(values[1:,1], values[1:,0], 'c1')
Comments
Post a Comment