方法seaborn.set_theme()不起作用
在 jupyter 笔记本中,我运行
import matplotlib as mpl
import matplotlib.pyplot as plt
import numpy as np
import pandas as pd
import seaborn as sns
import scipy.stats as stat
然后在另一个单元格中,我运行sns.set_theme(),出现以下错误
AttributeError: module 'seaborn' has no attribute 'set_theme'.
但它应该根据https://seaborn.pydata.org/tutorial/aesthetics.html
这是为什么?
回答
sns.set_theme()函数是在 v0.11 中添加的,您可能使用的是旧版本。安装 v0.11.0 或 v0.11.1
conda install seaborn=0.11
该功能以前以 名称存在sns.set,并且在较新版本上继续存在,因此更新不是绝对必要的。如果您想要旧版本 seaborn 上的功能,您可以运行seaborn.set(),它是sns.set_theme()0.11+ 中的别名。