<p dir="auto">Hello,<br>
first, thank you for this amazing library ! :)<br>
It is my first time reporting an issue, so please, feel free to let me know if anything is improper.</p>
<p dir="auto">The code for reproducibility</p>
<div class="highlight highlight-source-python notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="import seaborn as sns
import matplotlib.pyplot as plt
import pandas as pd

a = [0,1,2]
b = [1,0,1]

df = pd.DataFrame({&quot;a&quot;:a,&quot;b&quot;:b})
print(df)

plt.figure(figsize=(10,10))
sns.lineplot(data=df, x='a', y='b')
plt.show()"><pre class="notranslate"><span class="pl-k">import</span> <span class="pl-s1">seaborn</span> <span class="pl-k">as</span> <span class="pl-s1">sns</span>
<span class="pl-k">import</span> <span class="pl-s1">matplotlib</span>.<span class="pl-s1">pyplot</span> <span class="pl-k">as</span> <span class="pl-s1">plt</span>
<span class="pl-k">import</span> <span class="pl-s1">pandas</span> <span class="pl-k">as</span> <span class="pl-s1">pd</span>

<span class="pl-s1">a</span> <span class="pl-c1">=</span> [<span class="pl-c1">0</span>,<span class="pl-c1">1</span>,<span class="pl-c1">2</span>]
<span class="pl-s1">b</span> <span class="pl-c1">=</span> [<span class="pl-c1">1</span>,<span class="pl-c1">0</span>,<span class="pl-c1">1</span>]

<span class="pl-s1">df</span> <span class="pl-c1">=</span> <span class="pl-s1">pd</span>.<span class="pl-v">DataFrame</span>({<span class="pl-s">"a"</span>:<span class="pl-s1">a</span>,<span class="pl-s">"b"</span>:<span class="pl-s1">b</span>})
<span class="pl-en">print</span>(<span class="pl-s1">df</span>)

<span class="pl-s1">plt</span>.<span class="pl-en">figure</span>(<span class="pl-s1">figsize</span><span class="pl-c1">=</span>(<span class="pl-c1">10</span>,<span class="pl-c1">10</span>))
<span class="pl-s1">sns</span>.<span class="pl-en">lineplot</span>(<span class="pl-s1">data</span><span class="pl-c1">=</span><span class="pl-s1">df</span>, <span class="pl-s1">x</span><span class="pl-c1">=</span><span class="pl-s">'a'</span>, <span class="pl-s1">y</span><span class="pl-c1">=</span><span class="pl-s">'b'</span>)
<span class="pl-s1">plt</span>.<span class="pl-en">show</span>()</pre></div>
<p dir="auto">this is the error I get</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="  File &quot;.../venv/lib/python3.10/site-packages/numpy/ma/core.py&quot;, line 2360, in masked_invalid
    return masked_where(~(np.isfinite(getdata(a))), a, copy=copy)
TypeError: ufunc 'isfinite' not supported for the input types, and the inputs could not be safely coerced to any supported types according to the casting rule ''safe''"><pre class="notranslate"><code class="notranslate">  File ".../venv/lib/python3.10/site-packages/numpy/ma/core.py", line 2360, in masked_invalid
    return masked_where(~(np.isfinite(getdata(a))), a, copy=copy)
TypeError: ufunc 'isfinite' not supported for the input types, and the inputs could not be safely coerced to any supported types according to the casting rule ''safe''
</code></pre></div>
<p dir="auto">And finally, here is how I came around it : <code class="notranslate">numpy/ma/core.py</code></p>
<div class="highlight highlight-source-python notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="def getdata(a, subok=True):
    &quot;&quot;&quot;
    [...]
    &quot;&quot;&quot;
    try :  # added this
        data = a.to_numpy() # added this
    except AttributeError: # added this
        try:
            data = a._data
        except AttributeError:
            data = np.array(a, copy=False, subok=subok)
    if not subok:
        return data.view(ndarray)
    return data"><pre class="notranslate"><span class="pl-k">def</span> <span class="pl-en">getdata</span>(<span class="pl-s1">a</span>, <span class="pl-s1">subok</span><span class="pl-c1">=</span><span class="pl-c1">True</span>):
    <span class="pl-s">"""</span>
<span class="pl-s">    [...]</span>
<span class="pl-s">    """</span>
    <span class="pl-k">try</span> :  <span class="pl-c"># added this</span>
        <span class="pl-s1">data</span> <span class="pl-c1">=</span> <span class="pl-s1">a</span>.<span class="pl-en">to_numpy</span>() <span class="pl-c"># added this</span>
    <span class="pl-k">except</span> <span class="pl-v">AttributeError</span>: <span class="pl-c"># added this</span>
        <span class="pl-k">try</span>:
            <span class="pl-s1">data</span> <span class="pl-c1">=</span> <span class="pl-s1">a</span>.<span class="pl-s1">_data</span>
        <span class="pl-k">except</span> <span class="pl-v">AttributeError</span>:
            <span class="pl-s1">data</span> <span class="pl-c1">=</span> <span class="pl-s1">np</span>.<span class="pl-en">array</span>(<span class="pl-s1">a</span>, <span class="pl-s1">copy</span><span class="pl-c1">=</span><span class="pl-c1">False</span>, <span class="pl-s1">subok</span><span class="pl-c1">=</span><span class="pl-s1">subok</span>)
    <span class="pl-k">if</span> <span class="pl-c1">not</span> <span class="pl-s1">subok</span>:
        <span class="pl-k">return</span> <span class="pl-s1">data</span>.<span class="pl-en">view</span>(<span class="pl-s1">ndarray</span>)
    <span class="pl-k">return</span> <span class="pl-s1">data</span></pre></div>
<p dir="auto">the code was originally</p>
<div class="highlight highlight-source-python notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="    try:
        data = a._data
    except AttributeError:
        data = np.array(a, copy=False, subok=subok)
    if not subok:
        return data.view(ndarray)
    return data"><pre class="notranslate">    <span class="pl-k">try</span>:
        <span class="pl-s1">data</span> <span class="pl-c1">=</span> <span class="pl-s1">a</span>.<span class="pl-s1">_data</span>
    <span class="pl-k">except</span> <span class="pl-v">AttributeError</span>:
        <span class="pl-s1">data</span> <span class="pl-c1">=</span> <span class="pl-s1">np</span>.<span class="pl-en">array</span>(<span class="pl-s1">a</span>, <span class="pl-s1">copy</span><span class="pl-c1">=</span><span class="pl-c1">False</span>, <span class="pl-s1">subok</span><span class="pl-c1">=</span><span class="pl-s1">subok</span>)
    <span class="pl-k">if</span> <span class="pl-c1">not</span> <span class="pl-s1">subok</span>:
        <span class="pl-k">return</span> <span class="pl-s1">data</span>.<span class="pl-en">view</span>(<span class="pl-s1">ndarray</span>)
    <span class="pl-k">return</span> <span class="pl-s1">data</span></pre></div>
<p dir="auto">Before modifying the getdata function, I tried reinstalling seaborn, numpy, and matplotlib. But nothing worked.<br>
It now works.</p>
<p dir="auto">Hoping this can be of some help !</p>
<p dir="auto">Please, let me know if any information is missing.</p>
<hr>
<p dir="auto"><strong>requirements.txt</strong><br>
contourpy==1.0.6<br>
cycler==0.11.0<br>
fonttools==4.38.0<br>
geomloss==0.2.5<br>
kiwisolver==1.4.4<br>
matplotlib==3.6.2<br>
networkx==2.8.8<br>
numpy==1.24.0<br>
nvidia-cublas-cu11==11.10.3.66<br>
nvidia-cuda-nvrtc-cu11==11.7.99<br>
nvidia-cuda-runtime-cu11==11.7.99<br>
nvidia-cudnn-cu11==8.5.0.96<br>
packaging==22.0<br>
pandas==1.5.2<br>
Pillow==9.3.0<br>
POT==0.8.2<br>
pyparsing==3.0.9<br>
PyQt5==5.15.7<br>
PyQt5-Qt5==5.15.2<br>
PyQt5-sip==12.11.0<br>
PyQt6==6.4.0<br>
PyQt6-Qt6==6.4.1<br>
PyQt6-sip==13.4.0<br>
python-dateutil==2.8.2<br>
pytz==2022.7<br>
scipy==1.9.3<br>
seaborn==0.12.1<br>
six==1.16.0<br>
sklearn==0.0.post1<br>
tk==0.1.0<br>
torch==1.13.1<br>
tqdm==4.64.1<br>
typing_extensions==4.4.0</p>
<p dir="auto"><strong>system information</strong><br>
Python: Python 3.10.9<br>
Kernel: 5.15.0-56-generic x86_64<br>
bits: 64<br>
Desktop: Gnome 3.36.9<br>
Distro: Ubuntu 20.04.5 LTS (Focal Fossa)</p>
<p dir="auto">This is the code that I ran</p>
<div class="highlight highlight-source-python notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="import matplotlib.pyplot as plt
import seaborn as sns

fmri = sns.load_dataset(&quot;fmri&quot;)
fmri.info()

sns.set(style=&quot;darkgrid&quot;)
sns.lineplot(data=fmri, x=&quot;timepoint&quot;, y=&quot;signal&quot;, hue=&quot;region&quot;, style=&quot;event&quot;)

plt.show()"><pre class="notranslate"><span class="pl-k">import</span> <span class="pl-s1">matplotlib</span>.<span class="pl-s1">pyplot</span> <span class="pl-k">as</span> <span class="pl-s1">plt</span>
<span class="pl-k">import</span> <span class="pl-s1">seaborn</span> <span class="pl-k">as</span> <span class="pl-s1">sns</span>

<span class="pl-s1">fmri</span> <span class="pl-c1">=</span> <span class="pl-s1">sns</span>.<span class="pl-en">load_dataset</span>(<span class="pl-s">"fmri"</span>)
<span class="pl-s1">fmri</span>.<span class="pl-en">info</span>()

<span class="pl-s1">sns</span>.<span class="pl-en">set</span>(<span class="pl-s1">style</span><span class="pl-c1">=</span><span class="pl-s">"darkgrid"</span>)
<span class="pl-s1">sns</span>.<span class="pl-en">lineplot</span>(<span class="pl-s1">data</span><span class="pl-c1">=</span><span class="pl-s1">fmri</span>, <span class="pl-s1">x</span><span class="pl-c1">=</span><span class="pl-s">"timepoint"</span>, <span class="pl-s1">y</span><span class="pl-c1">=</span><span class="pl-s">"signal"</span>, <span class="pl-s1">hue</span><span class="pl-c1">=</span><span class="pl-s">"region"</span>, <span class="pl-s1">style</span><span class="pl-c1">=</span><span class="pl-s">"event"</span>)

<span class="pl-s1">plt</span>.<span class="pl-en">show</span>()</pre></div>
<p dir="auto">This is the error I got</p>
<div class="highlight highlight-source-python notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="❯ python3 example.py   
&lt;class 'pandas.core.frame.DataFrame'&gt;
RangeIndex: 1064 entries, 0 to 1063
Data columns (total 5 columns):
 #   Column     Non-Null Count  Dtype  
---  ------     --------------  -----  
 0   subject    1064 non-null   object 
 1   timepoint  1064 non-null   int64  
 2   event      1064 non-null   object 
 3   region     1064 non-null   object 
 4   signal     1064 non-null   float64
dtypes: float64(1), int64(1), object(3)
memory usage: 41.7+ KB
Traceback (most recent call last):
  File &quot;/home/rizwan/Downloads/Seaborn-Issue/example.py&quot;, line 8, in &lt;module&gt;
    sns.lineplot(
  File &quot;/home/rizwan/Miniconda3/envs/py39/lib/python3.9/site-packages/seaborn/relational.py&quot;, line 645, in lineplot
    p.plot(ax, kwargs)
  File &quot;/home/rizwan/Miniconda3/envs/py39/lib/python3.9/site-packages/seaborn/relational.py&quot;, line 489, in plot
    func(
  File &quot;/home/rizwan/Miniconda3/envs/py39/lib/python3.9/site-packages/matplotlib/__init__.py&quot;, line 1423, in inner
    return func(ax, *map(sanitize_sequence, args), **kwargs)
  File &quot;/home/rizwan/Miniconda3/envs/py39/lib/python3.9/site-packages/matplotlib/axes/_axes.py&quot;, line 5367, in fill_between
    return self._fill_between_x_or_y(
  File &quot;/home/rizwan/Miniconda3/envs/py39/lib/python3.9/site-packages/matplotlib/axes/_axes.py&quot;, line 5272, in _fill_between_x_or_y
    ind, dep1, dep2 = map(
  File &quot;/home/rizwan/Miniconda3/envs/py39/lib/python3.9/site-packages/numpy/ma/core.py&quot;, line 2360, in masked_invalid
    return masked_where(~(np.isfinite(getdata(a))), a, copy=copy)
TypeError: ufunc 'isfinite' not supported for the input types, and the inputs could not be safely coerced to any supported types according to the casting rule ''safe''"><pre class="notranslate">❯ <span class="pl-s1">python3</span> <span class="pl-s1">example</span>.<span class="pl-s1">py</span>   
<span class="pl-c1">&lt;</span><span class="pl-k">class</span> <span class="pl-s">'pandas.core.frame.DataFrame'</span><span class="pl-c1">&gt;</span>
<span class="pl-v">RangeIndex</span>: <span class="pl-c1">1064</span> <span class="pl-s1">entries</span>, <span class="pl-c1">0</span> <span class="pl-s1">to</span> <span class="pl-c1">1063</span>
<span class="pl-v">Data</span> <span class="pl-en">columns</span> (<span class="pl-s1">total</span> <span class="pl-c1">5</span> <span class="pl-s1">columns</span>):
 <span class="pl-c">#   Column     Non-Null Count  Dtype  </span>
<span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span>  <span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span>     <span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span>  <span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span>  
 <span class="pl-c1">0</span>   <span class="pl-s1">subject</span>    <span class="pl-c1">1064</span> <span class="pl-s1">non</span><span class="pl-c1">-</span><span class="pl-s1">null</span>   <span class="pl-s1">object</span> 
 <span class="pl-c1">1</span>   <span class="pl-s1">timepoint</span>  <span class="pl-c1">1064</span> <span class="pl-s1">non</span><span class="pl-c1">-</span><span class="pl-s1">null</span>   <span class="pl-s1">int64</span>  
 <span class="pl-c1">2</span>   <span class="pl-s1">event</span>      <span class="pl-c1">1064</span> <span class="pl-s1">non</span><span class="pl-c1">-</span><span class="pl-s1">null</span>   <span class="pl-s1">object</span> 
 <span class="pl-c1">3</span>   <span class="pl-s1">region</span>     <span class="pl-c1">1064</span> <span class="pl-s1">non</span><span class="pl-c1">-</span><span class="pl-s1">null</span>   <span class="pl-s1">object</span> 
 <span class="pl-c1">4</span>   <span class="pl-s1">signal</span>     <span class="pl-c1">1064</span> <span class="pl-s1">non</span><span class="pl-c1">-</span><span class="pl-s1">null</span>   <span class="pl-s1">float64</span>
<span class="pl-s1">dtypes</span>: <span class="pl-en">float64</span>(<span class="pl-c1">1</span>), <span class="pl-en">int64</span>(<span class="pl-c1">1</span>), <span class="pl-en">object</span>(<span class="pl-c1">3</span>)
<span class="pl-s1">memory</span> <span class="pl-s1">usage</span>: <span class="pl-c1">41.7</span><span class="pl-c1">+</span> <span class="pl-v">KB</span>
<span class="pl-v">Traceback</span> (<span class="pl-s1">most</span> <span class="pl-s1">recent</span> <span class="pl-s1">call</span> <span class="pl-s1">last</span>):
  <span class="pl-v">File</span> <span class="pl-s">"/home/rizwan/Downloads/Seaborn-Issue/example.py"</span>, <span class="pl-s1">line</span> <span class="pl-c1">8</span>, <span class="pl-s1">in</span> <span class="pl-c1">&lt;</span><span class="pl-s1">module</span><span class="pl-c1">&gt;</span>
    <span class="pl-s1">sns</span>.<span class="pl-s1">lineplot</span>(
  <span class="pl-v">File</span> <span class="pl-s">"/home/rizwan/Miniconda3/envs/py39/lib/python3.9/site-packages/seaborn/relational.py"</span>, <span class="pl-s1">line</span> <span class="pl-c1">645</span>, <span class="pl-s1">in</span> <span class="pl-s1">lineplot</span>
    <span class="pl-s1">p</span>.<span class="pl-en">plot</span>(<span class="pl-s1">ax</span>, <span class="pl-s1">kwargs</span>)
  <span class="pl-v">File</span> <span class="pl-s">"/home/rizwan/Miniconda3/envs/py39/lib/python3.9/site-packages/seaborn/relational.py"</span>, <span class="pl-s1">line</span> <span class="pl-c1">489</span>, <span class="pl-s1">in</span> <span class="pl-s1">plot</span>
    <span class="pl-s1">func</span>(
  <span class="pl-v">File</span> <span class="pl-s">"/home/rizwan/Miniconda3/envs/py39/lib/python3.9/site-packages/matplotlib/__init__.py"</span>, <span class="pl-s1">line</span> <span class="pl-c1">1423</span>, <span class="pl-s1">in</span> <span class="pl-s1">inner</span>
    <span class="pl-s1">return</span> <span class="pl-en">func</span>(<span class="pl-s1">ax</span>, <span class="pl-c1">*</span><span class="pl-en">map</span>(<span class="pl-s1">sanitize_sequence</span>, <span class="pl-s1">args</span>), <span class="pl-c1">**</span><span class="pl-s1">kwargs</span>)
  <span class="pl-v">File</span> <span class="pl-s">"/home/rizwan/Miniconda3/envs/py39/lib/python3.9/site-packages/matplotlib/axes/_axes.py"</span>, <span class="pl-s1">line</span> <span class="pl-c1">5367</span>, <span class="pl-s1">in</span> <span class="pl-s1">fill_between</span>
    <span class="pl-s1">return</span> <span class="pl-s1">self</span>.<span class="pl-s1">_fill_between_x_or_y</span>(
  <span class="pl-v">File</span> <span class="pl-s">"/home/rizwan/Miniconda3/envs/py39/lib/python3.9/site-packages/matplotlib/axes/_axes.py"</span>, <span class="pl-s1">line</span> <span class="pl-c1">5272</span>, <span class="pl-s1">in</span> <span class="pl-s1">_fill_between_x_or_y</span>
    <span class="pl-s1">ind</span>, <span class="pl-s1">dep1</span>, <span class="pl-s1">dep2</span> <span class="pl-c1">=</span> <span class="pl-s1">map</span>(
  <span class="pl-v">File</span> <span class="pl-s">"/home/rizwan/Miniconda3/envs/py39/lib/python3.9/site-packages/numpy/ma/core.py"</span>, <span class="pl-s1">line</span> <span class="pl-c1">2360</span>, <span class="pl-s1">in</span> <span class="pl-s1">masked_invalid</span>
    <span class="pl-s1">return</span> <span class="pl-en">masked_where</span>(<span class="pl-c1">~</span>(<span class="pl-s1">np</span>.<span class="pl-en">isfinite</span>(<span class="pl-en">getdata</span>(<span class="pl-s1">a</span>))), <span class="pl-s1">a</span>, <span class="pl-s1">copy</span><span class="pl-c1">=</span><span class="pl-s1">copy</span>)
<span class="pl-v">TypeError</span>: <span class="pl-s1">ufunc</span> <span class="pl-s">'isfinite'</span> <span class="pl-c1">not</span> <span class="pl-s1">supported</span> <span class="pl-k">for</span> <span class="pl-s1">the</span> <span class="pl-s1">input</span> <span class="pl-s1">types</span>, <span class="pl-s1">and</span> <span class="pl-s1">the</span> <span class="pl-s1">inputs</span> <span class="pl-s1">could</span> <span class="pl-c1">not</span> <span class="pl-s1">be</span> <span class="pl-s1">safely</span> <span class="pl-s1">coerced</span> <span class="pl-s1">to</span> <span class="pl-s1">any</span> <span class="pl-s1">supported</span> <span class="pl-s1">types</span> <span class="pl-s1">according</span> <span class="pl-s1">to</span> <span class="pl-s1">the</span> <span class="pl-s1">casting</span> <span class="pl-s1">rule</span> <span class="pl-s">''</span><span class="pl-s1">safe</span><span class="pl-s">''</span></pre></div>
<p dir="auto">Environment</p>
<ul dir="auto">
<li>Python <code class="notranslate">3.9.15</code></li>
<li>Seaborn <code class="notranslate">0.12.1</code></li>
<li>Matplotlib <code class="notranslate">3.6.2</code></li>
<li>Pandas <code class="notranslate">1.5.2</code></li>
<li>Numpy <code class="notranslate">1.24.0</code></li>
</ul>
<p dir="auto">This error only occurs when I use numpy <code class="notranslate">1.24.0</code>, version <code class="notranslate">1.23.5</code> or lower works as usual.</p>