【问题标题】:How to change matplotlib default settings to include white background on plots in Jupyter Notebook如何更改 matplotlib 默认设置以在 Jupyter Notebook 中的绘图上包含白色背景
【发布时间】:2020-05-19 13:06:35
【问题描述】:

我在 Jupyter Notebook 上使用深色主题,我发现当我使用 matplotlib 制作绘图时,绘图看起来像这样:

因此很难阅读刻度标签,因为看起来虽然情节背景是白色的,但这部分的背景是透明的。

我知道这可以通过使用以下代码行逐个情节地解决:

fig = plt.figure()
fig.patch.set_facecolor('white')
sns.scatterplot(train.X, train.y)

但是有没有办法设置 matplotlib 的全局属性,这样我就不需要每次都这样做了?

【问题讨论】:

标签: python matplotlib jupyter-notebook


【解决方案1】:

我能想到的最简单的:

sns.set()
sns.scatterplot(df.x,df.y)

输出:

【讨论】:

    猜你喜欢
    • 2014-10-04
    • 2019-11-16
    • 2018-08-12
    • 1970-01-01
    • 2020-10-12
    • 2013-07-20
    • 1970-01-01
    • 2017-04-06
    • 1970-01-01
    相关资源
    最近更新 更多