Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Color axis labels for pandas plotting on dark theme notebook

Tags:

python

pandas

I am using Jupyter Lab to plot some data using pandas plotting like this:

df.plot()

The trouble is that while the plot area is colored white, the axis labels are in black which is very difficult to see with a dark jupyter lab theme. Is there a way to make the entire plot background white so that I can see the labels. I have put an example image below.

enter image description here

like image 641
The Nightman Avatar asked May 24 '18 02:05

The Nightman


1 Answers

You can set a different style for matplotlib to use, which should override the default color choices. pandas uses matplotlib as its plotting library. You can see the available options on the documentation page or via:

from matplotlib import style

style.available
# returns:
['bmh',
 'classic',
 'dark_background',
 'fast',
 'fivethirtyeight',
 'ggplot',
 'grayscale',
 'seaborn-bright',
 'seaborn-colorblind',
 'seaborn-dark-palette',
 'seaborn-dark',
 'seaborn-darkgrid',
 'seaborn-deep',
 'seaborn-muted',
 'seaborn-notebook',
 'seaborn-paper',
 'seaborn-pastel',
 'seaborn-poster',
 'seaborn-talk',
 'seaborn-ticks',
 'seaborn-white',
 'seaborn-whitegrid',
 'seaborn',
 'Solarize_Light2',
 '_classic_test']

Since you are using a dark themed notebook, try a dark themed plot:

style.use('dark_background')
like image 95
James Avatar answered Nov 15 '22 01:11

James