-
Notifications
You must be signed in to change notification settings - Fork 2k
Open
Description
When setting seaborn.objects.Plot(df,x="x", y="y",..., color="single_value")
, where df["single_value"]
is a list of size df["x"]
with only a single value(say all ones), seaborn crashes with the error ValueError: 'alpha' must be between 0 and 1, inclusive
Ideally, this would just use a single color for the plot and label the single color if a legend is generated.
This dataframe fails
x = np.linspace(0, 10, 100)
df = {"x":x, "y":np.sin(x), "ymin": np.sin(x)*.9, "ymax": np.sin(x)*1.1, "color" : np.ones_like(x)}
And this dataframe succeeds
x = np.linspace(0, 10, 100)
df = {"x":x, "y":np.sin(x), "ymin": np.sin(x)*.9, "ymax": np.sin(x)*1.1, "color" : np.random.randint(0,3,size=np.shape(x))},
while running the following code
import numpy as np
import seaborn.objects as so
import matplotlib.pyplot as plt
fig, ax = plt.subplots(figsize=(10, 5))
p = (
so.Plot(
df,
x="x",
y="y",
ymin="ymin",
ymax="ymax",
color="color",
)
.add(so.Dots())
.add(so.Line(alpha=1))
.add(so.Range())
.add(so.Band())
.label(x="x", y="Leakage after 512 Circuit Depth")
.on(ax)
.show()
)
This is the link to the full error:
https://gist.github.com/AyushmaanAggarwal/33bf35fd0e4b6dc38b3de69bfc15d57a#file-full-error-seaborn-color
Metadata
Metadata
Assignees
Labels
No labels