python - 模块 Seaborn 没有属性 '<any graph>'

标签 python python-3.x seaborn

我无法从 ggplot2 切换到 seaborn。目前使用 Anaconda v. 4.5.8 和 Python 3.6.3

找不到我使用的任何图表。例如,我可以从 seaborn 的站点获取任何代码并运行:

import matplotlib as plt
import seaborn as sns
sns.set(style="ticks")

dots = sns.load_dataset("dots")

# Define a palette to ensure that colors will be
# shared across the facets
palette = dict(zip(dots.coherence.unique(),
                   sns.color_palette("rocket_r", 6)))

# Plot the lines on two facets
sns.relplot(x="time", y="firing_rate",
            hue="coherence", size="choice", col="align",
            size_order=["T1", "T2"], palette=palette,
            height=5, aspect=.75, facet_kws=dict(sharex=False),
            kind="line", legend="full", data=dots)
sns.plt.show() #this was not on site code but tried it(plt.show() as referenced by other posts)

错误信息:

  File "<ipython-input-8-893759310442>", line 13, in <module>
    sns.relplot(x="time", y="firing_rate",

AttributeError: module 'seaborn' has no attribute 'relplot'

看过这些帖子(以及其他)

(1) AtributeError: 'module' object has no attribute 'plt' - Seaborn

(2) Seaborn ImportError: DLL load failed: 找不到指定的模块

(3) pip安装成功后的ImportError

(4) 在 Python 中导入 Seaborn 模块时出错

并尝试了他们描述的安装/卸载方法(python -m pip install seaborn、卸载 seaborn/重新安装等)我在 conda 中使用 conda 和 cmd 使用 pip 都这样做了。

我没有花太多时间在 PATH 上,但这里是屏幕截图:

conda

pip

有什么想法吗?

非常感谢

最佳答案

您在 seaborn 模块的 最新 版本中找到了该示例,即 0.9。来自 "What’s new in each version"部分:

New relational plots

Three completely new plotting functions have been added: relplot(), scatterplot(), and lineplot()

因此,您需要将 seaborn 更新到最新版本才能使用这些绘图功能。

关于python - 模块 Seaborn 没有属性 '<any graph>',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51402579/

相关文章:

python - 是否有 Google Insights API?

python - 在 python 中处理文件路径

pandas - 每个列数据框的分布概率,在一个图中

python - 将辅助 y 轴刻度与主 x 轴上的带状图对齐

python - DRF(Django)层次结构

Python lambda自组合函数: How to return a function that is repeated n amount of times?

python - MongoDB 聚合 - 按不同对分组

python - 有 python3 的 web.py 吗?

python-3.x - 使用 shift() 比较行元素

python - 如何在条形图上添加值标签