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:
Any ideas?
Many Thanks
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.
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
conda remove seaborn conda install seaborn=0.9.0
which still installed an older version. I finally got it to work using 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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With