Python seaborn histplot returns StopIteration

1.5k views Asked by At

I installed seaborn, but when I do the example from the Seaborn website, I get StopIteration message, how do I fix it?

import seaborn as sns penguins = sns.load_dataset("penguins") sns.histplot(data=penguins, x="flipper_length_mm")

StopIteration Traceback (most recent call last) Cell In [33], line 1 ----> 1 sns.histplot(data=penguins, x="flipper_length_mm")

image

2

There are 2 answers

1
Roger Compte On

The problem seem to be in the default color definition function. If you specify a color you can skip the error:

sns.histplot(data=penguins, x="flipper_length_mm", color='blue')

That solved the problem for me, hope it does for you as well. Cheers

0
Alex On

The problem is with matplotlib==3.6.1

You have 2 variants:

  1. Upgrade matplotlib up to 3.6.2 version via
pip install matplotlib --upgrade
  1. Downgrade matplotlib to 3.6.0 version via
pip install matplotlib==3.6.0 --force-reinstall

Both variants worked for me.
Here is the same issue on GitHub: https://github.com/mwaskom/seaborn/issues/3072