【问题标题】:Matplotlib: matplotlibrc file ignored after seaborn import [duplicate]Matplotlib:seaborn导入后忽略matplotlibrc文件[重复]
【发布时间】:2017-11-15 08:13:10
【问题描述】:

我有一个带有 matplotlib 配置选项的自定义 matplotlibrc 文件,遵循过程 here。当我第一次启动 Jupyter QtConsole(通过终端,如果这很重要)时,正在读取文件——绘图使用我设置的选项,例如虚线网格线:

%matplotlib inline

plt.plot([1, 2, 3])
Out[2]: [<matplotlib.lines.Line2D at 0x9d2fe80>]

matplotlibrc 文件在这里:

mpl.matplotlib_fname()
Out[4]: 'C:\\Users\\my_username\\.matplotlib\\matplotlibrc'

但是如果我导入 seaborn:

import seaborn as sns

情节然后切换到 seaborn 风格:

plt.plot([1, 2, 3])
Out[6]: [<matplotlib.lines.Line2D at 0xceb9cc0>]

是否可以在导入seaborn的同时保留原来的绘图风格?我想使用它的功能,例如seaborn.heatmap,但不是它的样式。

【问题讨论】:

  • 这些文件是否导入seaborn?这就是 seaborn 风格。
  • 很好,是的,就是这样。编辑了我的问题,因为这完全导致了另一个问题。

标签: python matplotlib seaborn qtconsole


【解决方案1】:

代替:

import seaborn as sns

用途:

import seaborn.apionly as sns

您获得了 API,但没有样式。开发人员为那些想要 Seaborn 的功能而不需要其自定义外观的人提供了此选项。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2014-02-24
    • 2020-02-17
    • 2019-08-20
    • 2016-10-22
    • 1970-01-01
    • 1970-01-01
    • 2023-03-24
    相关资源
    最近更新 更多