If i have a pandas dataframe:
x = pd.DataFrame(np.random.randn(5,5), columns = ['0','1.1','1.2', '2.1', '2.2'])
and would like to plot it like this:
x.plot()
How do i color them by groups, like 0 in one color, 1.1 and 1.2 in one color, 2.1 and 2.2 in one color. I would like the legend still to say all five types
CodePudding user response:
You could just add a list of colors with the length of number of plots:
Instead of x.plot()
you write:
x.plot(color=['r', 'g', 'g', 'b', 'b']) # red green green blue blue