Open joaofauvel opened 1 year ago
Thanks for the clear report. Interestingly, when I tried to reduce it to an even simpler example that should have the same characteristics (integer type data with a nominal scale) I'm getting the expected behavior:
import seaborn as sns
import seaborn.objects as so
(
so.Plot(x=[1, 2, 3], y=[1, 2, 3], color=[1, 2, 3])
.add(so.Dot())
.scale(color=so.Nominal())
)
So something complicated is happening here...
I ran into the same error. It seems it relates to using multiple add
method. The code below reproduces the error.
Seaborn version: 0.13.0
import seaborn.objects as so
(
so.Plot(x=[1, 2, 3], y=[1, 2, 3], color=[1, 2, 3])
.add(so.Dot())
.add(so.Dot(), x=[1], y=[1], color=[1])
.scale(color=so.Nominal())
)
Any updates with regards to this issue?
Setting the color param with an integer series on so.Plot.add and then setting the color param on so.Plot.scale to a qualitative palette raises
PlotSpecError: Scaling operation failed for the color variable
. If the color palette is sequential, no error is raised. I don't believe this is intended, given that it works when the series is casted to a str, category, or float.Example:
Traceback
``` IndexError Traceback (most recent call last) File /opt/conda/lib/python3.10/site-packages/seaborn/_marks/base.py:179, in Mark._resolve(self, data, name, scales) 178 try: --> 179 feature = scale(value) 180 except Exception as err: File /opt/conda/lib/python3.10/site-packages/seaborn/_core/scales.py:129, in Scale.__call__(self, data) 128 if func is not None: --> 129 trans_data = func(trans_data) 131 if scalar_data: File /opt/conda/lib/python3.10/site-packages/seaborn/_core/properties.py:682, in Color._get_nominal_mapping.