0

I have the following code which produces a line plot with Financial Years on the X axis, and Count on the Y axis. It is done with matplotlib, and uses a dataframe called DF.

How do I change the colours of the lines to my choosing? I have done some googling, but all the examples I come across, do not use examples of a dataframe, they are all line plots from an X and Y series.

Could anyone help? (I have removed the styling from the following code for brevity)

fig, ax = plt.subplots()
DF.plot(ax=ax)

The dataframe is like this:

Cars        A    B   C
2011/2012   270 186 NaN
2012/2013   306 369 396.0
2013/2014   375 369 315.0
2014/2015   745 397 237.0
2015/2016   427 409 171.0
2016/2017   403 448 213.0
2017/2018   461 563 NaN


Index: 7 entries, 2011/2012 to 2017/2018
Data columns (total 3 columns):
A                   7 non-null object
B                   7 non-null object
C                   5 non-null float64
dtypes: float64(1), object(2)
ImportanceOfBeingErnest
  • 321,279
  • 53
  • 665
  • 712
Nicholas
  • 3,517
  • 13
  • 47
  • 86

1 Answers1

0

You'd just set the color attribute to the color you want:

https://matplotlib.org/users/colors.html
mattsap
  • 3,790
  • 1
  • 15
  • 36
  • I am confused. The example you sent does not use a Dataframe, which is what I am struggling to understand. It has multiple plots using '(th, np.cos(th)'. I do not understand what that is, and how I can do it with a dataframe :S – Nicholas Jan 24 '19 at 19:41