1

When I run sns.pairplot on my data, I get the following error:

another_1.py:6: MatplotlibDeprecationWarning: The seaborn styles shipped by Matplotlib are deprecated since 3.6, as they no longer correspond to the styles shipped by seaborn. However, they will remain available as 'seaborn-v0_8-<style>'. Alternatively, directly use the seaborn API instead.
  plt.style.use("seaborn")
Traceback (most recent call last):
  File "another_1.py", line 18, in <module>
    sns.pairplot(hept)
  File "/Users/usr/MLmodule/venv/lib/python3.8/site-packages/seaborn/axisgrid.py", line 2144, in pairplot
    grid.map_diag(histplot, **diag_kws)
  File "/Users/usr/MLmodule/venv/lib/python3.8/site-packages/seaborn/axisgrid.py", line 1507, in map_diag
    func(x=vector, **plot_kwargs)
  File "/Users/usr/MLmodule/venv/lib/python3.8/site-packages/seaborn/distributions.py", line 1418, in histplot
    color = _default_color(method, hue, color, kwargs)
  File "/Users/usr/MLmodule/venv/lib/python3.8/site-packages/seaborn/utils.py", line 139, in _default_color
    scout, = method([np.nan], [np.nan], **kws)
  File "/Users/usr/MLmodule/venv/lib/python3.8/site-packages/matplotlib/__init__.py", line 1423, in inner
    return func(ax, *map(sanitize_sequence, args), **kwargs)
  File "/Users/usr/MLmodule/venv/lib/python3.8/site-packages/matplotlib/axes/_axes.py", line 2373, in bar
    width = self._convert_dx(width, x0, x, self.convert_xunits)
  File "/Users/usr/MLmodule/venv/lib/python3.8/site-packages/matplotlib/axes/_axes.py", line 2182, in _convert_dx
    x0 = cbook._safe_first_finite(x0)
  File "/Users/usr/MLmodule/venv/lib/python3.8/site-packages/matplotlib/cbook/__init__.py", line 1749, in _safe_first_finite
    return next(val for val in obj if safe_isfinite(val))
StopIteration

sample data:

data = {"Name":["Thiam","Ennis-Hill","Theisen Eaton","Ikauniece-Admidina","Schafer","Johnson-Thompson","Rodriguez","Zsivoczky-Farkas","Oeser","Vetter"],"hurdles":[13.56,12.84,13.18,13.33,13.12,13.48,13.61,13.79,13.69,13.47],"highjump":[1.98,1.89,1.86,1.77,1.83,1.98,1.86,1.86,1.86,1.77],"shotput":[14.91,13.86,13.45,13.52,14.57,11.68,13.69,14.39,14.28,14.78],"run200m":[25.1,23.49,24.18,23.76,23.99,23.26,24.26,25.38,24.99,23.93],"longjump":[6.58,6.34,6.48,6.12,6.2,6.51,6.25,6.31,6.1,6.1],"javelin":[53.13,46.06,47.36,55.93,47.99,36.36,48.89,48.07,47.22,48.42],"run800m":[136.5,129.1,129.5,129.4,136.5,130.5,134.7,131.8,133.8,137.7]}

Here is the sample code that I use to run on the data:

import matplotlib.pyplot as plt
import seaborn as sns
import pandas as pd
plt.style.use("seaborn")


hept= pd.DataFrame(data)
hept

events=hept.T.index
events

sns.set()
sns.pairplot(hept)

I am running this on visual studio code

1
  • 1
    Your code runs fine. Try updating your modules: pip install -U pandas matplotlib seaborn
    – Tranbi
    Commented Oct 22, 2022 at 14:52

1 Answer 1

0

I had the same issue while using python 3.10.0, I downgraded to version python 3.8.8, and it runs smoothly, try using another version.

I run your script with py 3.8.8 and I get the pairplot sns.pairplot(hept)

Not the answer you're looking for? Browse other questions tagged or ask your own question.