Matplotlib 提供的seaborn 样式自 3.6 起已弃用

Dav*_*mad 8 python matplotlib seaborn deprecation-warning

Matplotlib 提供的seaborn 样式自3.6 起已弃用,因为它们不再对应于seaborn 提供的样式。但是,它们仍将以“seaborn-v0_8-<style>”形式提供。或者,直接使用seaborn API。

我已经尝试过这个:

# use seaborn style
plt.style.use("seaborn")
Run Code Online (Sandbox Code Playgroud)

但它已被弃用,我想在 Windows 中使用 cmd 时删除此警告

Tra*_*nbi 18

此警告告诉您 matplotlib 中的seaborn 样式与当前的seaborn 样式不匹配,因为最新的seaborn 样式已更新。

这就是为什么您应该按如下方式设置样式:

plt.style.use("seaborn-v0_8")
Run Code Online (Sandbox Code Playgroud)

<style>您可以通过替换以下内容来指定主题:

  • 明亮的
  • 色盲
  • 黑暗的
  • 深色调色板
  • 暗格
  • 深的
  • 静音
  • 笔记本
  • 柔和的
  • 海报
  • 讲话
  • 蜱虫
  • 白色的
  • 白色网格

像这样:

plt.style.use("seaborn-v0_8-whitegrid")
Run Code Online (Sandbox Code Playgroud)

或者,如果您想使用最新的seaborn样式,请直接使用他们的

编辑:添加缺失的主题以确保完整性。