gpt4 book ai didi

python - Matplotlib:seaborn 导入后忽略 matplotlibrc 文件

转载 作者:行者123 更新时间:2023-11-30 22:35:35 25 4
gpt4 key购买 nike

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

%matplotlib inline

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

enter image description here

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>]

enter image description here

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

最佳答案

而不是:

import seaborn as sns

用途:

import seaborn.apionly as sns

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

关于python - Matplotlib:seaborn 导入后忽略 matplotlibrc 文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44523369/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com