Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I get the standard colors used in pandas dataframe or series plot?

Pandas plot with multiple graphs has this standard colors (the first four colors are shown here):

enter image description here

How can I get programmatically these four colors and the following ones?

like image 753
Alessandro Jacopson Avatar asked Oct 21 '25 04:10

Alessandro Jacopson


1 Answers

You are referring to category10 color palette:

enter image description here

Programmatically you can access them through:

import matplotlib.pyplot as plt
plt.rcParams['axes.prop_cycle'].by_key()['color']
['#1f77b4',
 '#ff7f0e',
 '#2ca02c',
 '#d62728',
 '#9467bd',
 '#8c564b',
 '#e377c2',
 '#7f7f7f',
 '#bcbd22',
 '#17becf']

See this page of the matplotlib docs or this SO question for more info.

like image 197
jorijnsmit Avatar answered Oct 23 '25 19:10

jorijnsmit