You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
TypeErrorTraceback (mostrecentcalllast)
Fileexample.py:31importseabornassns2df=sns.load_dataset('attention', index_col=0)
---->3sns.scatterplot(df, x='subject', y='score', s=df['solutions']*20, hue='attention')
File~/.local/opt/mambaforge/envs/ml/lib/python3.10/site-packages/seaborn/relational.py:624, inscatterplot(data, x, y, hue, size, style, palette, hue_order, hue_norm, sizes, size_order, size_norm, markers, style_order, legend, ax, **kwargs)
621color=kwargs.pop("color", None)
622kwargs["color"] =_default_color(ax.scatter, hue, color, kwargs)
-->624p.plot(ax, kwargs)
626returnaxFile~/.local/opt/mambaforge/envs/ml/lib/python3.10/site-packages/seaborn/relational.py:458, in_ScatterPlotter.plot(self, ax, kws)
456ifself.legend:
457attrs= {"hue": "color", "size": "s", "style": None}
-->458self.add_legend_data(ax, _scatter_legend_artist, kws, attrs)
459handles, _ =ax.get_legend_handles_labels()
460ifhandles:
File~/.local/opt/mambaforge/envs/ml/lib/python3.10/site-packages/seaborn/_base.py:1270, inVectorPlotter.add_legend_data(self, ax, func, common_kws, attrs, semantic_kws)
1268ifattrinkws:
1269level_kws[attr] =kws[attr]
->1270artist=func(label=label, **{"color": ".2", **common_kws, **level_kws})
1271if_version_predates(mpl, "3.5.0"):
1272ifisinstance(artist, mpl.lines.Line2D):
File~/.local/opt/mambaforge/envs/ml/lib/python3.10/site-packages/seaborn/utils.py:927, in_scatter_legend_artist(**kws)
924else:
925line_kws["markeredgecolor"] =edgecolor-->927returnmpl.lines.Line2D([], [], **line_kws)
File~/.local/opt/mambaforge/envs/ml/lib/python3.10/site-packages/matplotlib/lines.py:393, inLine2D.__init__(self, xdata, ydata, linewidth, linestyle, color, gapcolor, marker, markersize, markeredgewidth, markeredgecolor, markerfacecolor, markerfacecoloralt, fillstyle, antialiased, dash_capstyle, solid_capstyle, dash_joinstyle, solid_joinstyle, pickradius, drawstyle, markevery, **kwargs)
391self.set_markevery(markevery)
392self.set_antialiased(antialiased)
-->393self.set_markersize(markersize)
395self._markeredgecolor=None396self._markeredgewidth=NoneFile~/.local/opt/mambaforge/envs/ml/lib/python3.10/site-packages/matplotlib/lines.py:1265, inLine2D.set_markersize(self, sz)
1256defset_markersize(self, sz):
1257""" 1258 Set the marker size in points. 1259 (...) 1263 Marker size, in points. 1264 """->1265sz=float(sz)
1266ifself._markersize!=sz:
1267self.stale=TrueFile~/.local/opt/mambaforge/envs/ml/lib/python3.10/site-packages/pandas/core/series.py:248, in_coerce_method.<locals>.wrapper(self)
240warnings.warn(
241f"Calling {converter.__name__} on a single element Series is "242"deprecated and will raise a TypeError in the future. "
(...)
245stacklevel=find_stack_level(),
246 )
247returnconverter(self.iloc[0])
-->248raiseTypeError(f"cannot convert the series to {converter}")
TypeError: cannotconverttheseriesto<class'float'>
This applies to versions:
0.13.2
0.13.1
0.13.0
but not to 0.12.2. I did not test current git development version.
When calling scatterplot with hue a legend will be added. Together with s with different sizes this bug is triggered. The bug is not triggered, when...
setting legend=False
removing the hue argument (because no legend)
removing the s argument
setting the s argument to a scaler, like s=20
My interpretation is that the legend artist should receive a scaler, but gets an array. So maybe this issue has the same roots as #3575.
The text was updated successfully, but these errors were encountered:
I do think it’s a real issue and know the cause (0.13.0 started propagating more user kwargs to the legend artists, but artists don’t have a s parameter). Just mentioning size= as in most cases I’d think that’s preferred (you don’t need to scale the units yourself and you get a legend).
This small example
results in a
TypeError
.Traceback
This applies to versions:
but not to 0.12.2. I did not test current git development version.
When calling
scatterplot
withhue
a legend will be added. Together withs
with different sizes this bug is triggered. The bug is not triggered, when...legend=False
hue
argument (because no legend)s
arguments
argument to a scaler, likes=20
My interpretation is that the legend artist should receive a scaler, but gets an array. So maybe this issue has the same roots as #3575.
The text was updated successfully, but these errors were encountered: