在深色主题笔记本上绘制熊猫的色轴标签

The*_*man 6 python pandas

我正在使用 Jupyter Lab 使用 Pandas 绘图来绘制一些数据,如下所示:

df.plot()
Run Code Online (Sandbox Code Playgroud)

问题是,虽然绘图区域是白色的,但轴标签是黑色的,这在深色 jupyter 实验室主题下很难看到。有没有办法使整个情节背景变白,以便我可以看到标签。我在下面放了一个示例图片。

在此处输入图片说明

Jam*_*mes 8

您可以设置不同的样式以matplotlib供使用,该样式应覆盖默认颜色选择。 pandas使用matplotlib它的绘图库。您可以在文档页面或通过以下方式查看可用选项:

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']
Run Code Online (Sandbox Code Playgroud)

由于您使用的是深色主题笔记本,请尝试使用深色主题的情节:

style.use('dark_background')
Run Code Online (Sandbox Code Playgroud)