Seaborn Lineplot Module Object Has No Attribute 'Lineplot'

巧了我就是萌 提交于 2021-02-08 12:17:20

问题


Using seaborn's documentation code to generate a lineplot returns an AttributeError: 'module' object has no attribute 'lineplot'. I have updated seaborn and reimported the module and tried again, no luck. Did lineplot get retired, or is there something else going on?

import seaborn as sns; sns.set()
import matplotlib.pyplot as plt
fmri = sns.load_dataset("fmri")
ax = sns.lineplot(x="timepoint", y="signal", data=fmri)

回答1:


If you are using conda, you need to install seaborn with the version specified:

conda install -c anaconda seaborn=0.9.0

Once your seaborn 0.9.0 is installed properly, you should be able to use the lineplot function (at least it works on mine).

That way you don't have to go outside of the conda ecosystem and use seaborn with pip.




回答2:


Lineplot works with update to seaborn 0.9. conda has not yet integrated seaborn 0.9.0 into it's default channel, which is why the update to 0.9 failed on my first go.

Couldn't Update Seaborn via Default Channel but found another way to do it through this answer




回答3:


As other's said before, you need seaborn version 0.9.0 (or above will work too, I guess). The pip-way of doing this without conda is:

pip install seaborn==0.9.0

My problem was that I had an older version ( 0.8.x) installed, so simply running pip install seaborn doesn't help in that case.

Alternatively, you can directly upgrade to the latest version of seaborn like this:

pip install -U seaborn



回答4:


Within Jupyter notebook you can run the install without leaving the notebook.

You only have to add the tag "y" to install the package.

!conda install -y -c anaconda seaborn=0.9.0


来源:https://stackoverflow.com/questions/51846948/seaborn-lineplot-module-object-has-no-attribute-lineplot

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!