mwaskom / seaborn

Statistical data visualization in Python
https://seaborn.pydata.org
BSD 3-Clause "New" or "Revised" License
12.54k stars 1.92k forks source link

scatterplot bug in 0.13.0 #3575

Open CommonClimate opened 11 months ago

CommonClimate commented 11 months ago

Hello and first off, major thanks to @mwaskom for this incredible package. I report this bug as a developer of Pyleoclim, which has seaborn as a dependency.

In upgrading to Python 3.11, we also upgraded to seaborn 0.13.0, and this docstring example starting giving us grief. Specifically:

Traceback (most recent call last):

  Cell In[3], line 17
    gs.map_neighbors(mgs, radius=4000)

  File ~/Documents/GitHub/Pyleoclim_util/pyleoclim/core/geoseries.py:446 in map_neighbors
    fig, ax_d = mapping.scatter_map(neighborhood, fig=fig, gs_slot=gridspec_slot, hue=hue, size=size, marker=marker, projection=projection,

  File ~/Documents/GitHub/Pyleoclim_util/pyleoclim/utils/mapping.py:1205 in scatter_map
    _, ax_d = plot_scatter(df=df, x=x, y=y, hue_var=hue, size_var=size, marker_var=marker, ax_d=ax_d, proj=None, edgecolor=edgecolor,

  File ~/Documents/GitHub/Pyleoclim_util/pyleoclim/utils/mapping.py:946 in plot_scatter
    sns.scatterplot(data=hue_data, x=x, y=y, hue=hue_var, size=size_var,transform=transform, #change to transform=scatter_kwargs['transform']

  File ~/opt/miniconda3/envs/pyleo/lib/python3.11/site-packages/seaborn/relational.py:624 in scatterplot
    p.plot(ax, kwargs)

  File ~/opt/miniconda3/envs/pyleo/lib/python3.11/site-packages/seaborn/relational.py:458 in plot
    self.add_legend_data(ax, _scatter_legend_artist, kws, attrs)

  File ~/opt/miniconda3/envs/pyleo/lib/python3.11/site-packages/seaborn/_base.py:1270 in add_legend_data
    artist = func(label=label, **{"color": ".2", **common_kws, **level_kws})

  File ~/opt/miniconda3/envs/pyleo/lib/python3.11/site-packages/seaborn/utils.py:922 in _scatter_legend_artist
    if edgecolor == "face":

ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()

The problem goes away if I revert to seaborn 0.12.2, keeping all other packages the same. My environment.yml is copied to help troubleshoot. It seems that it the fix could be a minor change in _scatter_legend_artist but I don't have a good sense of the ramifications.

Best, J.E.G.

-- name: pyleo channels:

mwaskom commented 11 months ago

Can you please craft a reproducible example that uses seaborn directly? It's going to be necessary to understand how your library is using seaborn to make any sense of what might be happening here, and you're going to be in a much better position to do that than I am.

CommonClimate commented 11 months ago

Yes, I'll be happy to. The student who wrote that part of our code is currently sick, but when they get better I will work with them to pare down the code and provide a seaborn-only MWE.