Module Seaborn has no attribute '<any graph>'

HowdyDude picture HowdyDude · Jul 18, 2018 · Viewed 79k times · Source

I am having trouble switching from ggplot2 into seaborn. Currently using Anaconda v. 4.5.8 and Python 3.6.3

Any graph I use cannot be found. For example I can take any code from seaborn's site and run:

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

(2) Seaborn ImportError: DLL load failed: The specified module could not be found

(3) ImportError after successful pip installation

(4) Error importing Seaborn module in Python

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.

I haven't spent much time with PATHs but here are screenshots:

conda

pip

Any ideas?

Many Thanks

Answer

DavidG picture DavidG · Jul 18, 2018

You have found that example on the newest version of the seaborn module, which is 0.9. From the "What’s new in each version" section:

New relational plots

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

So, you need to update your seaborn to the latest version to use these plotting functions.