且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何在不更改 matplotlib 默认值的情况下使用 seaborn?

更新时间:2022-05-11 01:39:47

0.8 版(2017 年 7 月)改变了这种行为.来自 https://seaborn.pydata.org/whatsnew.html#v0-8-0-july-2017:

Version 0.8 (july 2017) changed this behaviour. From https://seaborn.pydata.org/whatsnew.html#v0-8-0-july-2017:

seaborn 时不再应用默认(seaborn)样式进口的.现在需要显式调用 set() 或一个或多个set_style()、set_context() 和 set_palette().相应地,seaborn.apionly 模块已被弃用.

The default (seaborn) style is no longer applied when seaborn is imported. It is now necessary to explicitly call set() or one or more of set_style(), set_context(), and set_palette(). Correspondingly, the seaborn.apionly module has been deprecated.

对于旧版本,像这样导入 seaborn:

For older versions, Import seaborn like this:

import seaborn.apionly as sns

然后你应该能够使用 sns.distplot 但保持默认的 matplotlib 样式 + 你的个人 rc 配置.

and then you should be able to use sns.distplot but maintain the default matplotlib styling + your personal rc configuration.