如何在不更改 matplotlib 默认值的情况下使用 seaborn? [英] How can I use seaborn without changing the matplotlib defaults?

查看:48
本文介绍了如何在不更改 matplotlib 默认值的情况下使用 seaborn?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用 seaborn,因为它具有 distplot 功能.但我更喜欢默认的 matplotlib 设置.当我导入 seaborn 时,它会自动改变我的身材.

I am trying to use seaborn, because of its distplot function. But I prefer the default matplotlib settings. When I import seaborn, it changes automatically the appearance of my figure.

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

How can I use seaborn functions without changing the look of the plots?

推荐答案

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.

这篇关于如何在不更改 matplotlib 默认值的情况下使用 seaborn?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆