Python 模块 Seaborn 没有属性 '<any graph>'
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/51402579/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Module Seaborn has no attribute '<any graph>'
提问by HowdyDude
I am having trouble switching from ggplot2 into seaborn. Currently using Anaconda v. 4.5.8 and Python 3.6.3
我在从 ggplot2 切换到 seaborn 时遇到了问题。目前使用 Anaconda v. 4.5.8 和 Python 3.6.3
Any graph I use cannot be found. For example I can take any code from seaborn's site and run:
找不到我使用的任何图表。例如,我可以从 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)
Error message:
错误信息:
File "<ipython-input-8-893759310442>", line 13, in <module>
sns.relplot(x="time", y="firing_rate",
AttributeError: module 'seaborn' has no attribute 'relplot'
Looked at these posts( among others)
看了这些帖子(等等)
(1) AtributeError: 'module' object has no attribute 'plt' - Seaborn
(1) AtributeError: 'module' 对象没有属性 'plt' - Seaborn
(2) Seaborn ImportError: DLL load failed: The specified module could not be found
(2) Seaborn ImportError: DLL load failed: The specified module could not be found
(3) ImportError after successful pip installation
(3) pip安装成功后ImportError
(4) Error importing Seaborn module in Python
(4)Python导入Seaborn模块出错
and tried the install/uninstall methods they described ( python -m pip install seaborn, uninstall seaborn/ reinstall - etc.) I did this in both conda using conda and cmd using pip.
并尝试了他们描述的安装/卸载方法(python -m pip install seaborn、uninstall seaborn/reinstall - 等)我在 conda 中使用 conda 和 cmd 使用 pip 执行了此操作。
I haven't spent much time with PATHs but here are screenshots:
我没有花太多时间在 PATHs 上,但这里有截图:
Any ideas?
有任何想法吗?
Many Thanks
非常感谢
回答by DavidG
You have found that example on the newestversion of the seaborn module, which is 0.9
. From the "What's new in each version"section:
您已经在最新版本的 seaborn 模块上找到了该示例,即0.9
. 从“每个版本的新增功能”部分:
New relational plots
Three completely new plotting functions have been added: relplot(), scatterplot(), and lineplot()
新的关系图
添加了三个全新的绘图函数:relplot()、scatterplot() 和 lineplot()
So, you need to update your seaborn to the latest version to use these plotting functions.
因此,您需要将您的 seaborn 更新到最新版本才能使用这些绘图功能。
回答by Jonathan Fry
I had this same issue. The selected answer, is correct, you have an older version, but there were a few hangups that I ran into. Here's what happened and how I corrected it. I first tried:
我有同样的问题。所选答案是正确的,您有一个旧版本,但我遇到了一些问题。这是发生的事情以及我如何纠正它。我第一次尝试:
conda update seaborn
which did not install seaborn 0.9.0, but rather installed a 0.8.x version. I then did
它没有安装 seaborn 0.9.0,而是安装了 0.8.x 版本。然后我做了
conda remove seaborn
conda install seaborn=0.9.0
which still installed an older version. I finally got it to work using pip3
仍然安装了旧版本。我终于使用 pip3 让它工作了
pip3 install seaborn==0.9.0
Which worked properly and solved the missing plots you mentioned. As long as you do this within your conda environment, it should function as though it was a conda install.
哪个工作正常并解决了您提到的缺失图。只要您在 conda 环境中执行此操作,它就应该像 conda 安装一样运行。
回答by Loc Nguyen
First uninstall seaborn:
首先卸载seaborn:
conda remove seaborn
pip uninstall seaborn
Then try download and install lastest version:
然后尝试下载并安装最新版本:
pip3 --no-cache-dir install seaborn
It worked for me.
它对我有用。