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

How can I use seaborn without changing the matplotlib defaults?

我正在尝试使用seaborn,因为它具有distplot功能。 但是我更喜欢默认的matplotlib设置。 导入seaborn时,它会自动更改图形的外观。

如何在不改变地块外观的情况下使用seaborn函数?


0.8版(2017年7月)更改了此行为。 来自https://seaborn.pydata.org/whatsnew.html:

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:

1
import seaborn.apionly as sns

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


根据文档reset_orig,将所有RC参数恢复为原始设置:

1
2
3
import seaborn as sns
# reset RC params to original
sns.reset_orig()