I get this error when setting color (using the example from the documentation, see below):
Traceback (most recent call last):
File "/media/me/364b201e-3416-4537-bb16-98314b1ef284/git/gizur-trade-rndfy25/sep2024/plotnine/color_bug.py", line 32, in <module>
p.show()
File "/home/me/.pyenv/versions/3.9.7/lib/python3.9/site-packages/plotnine/ggplot.py", line 150, in show
self._display() if is_inline_backend() else self.draw(show=True)
File "/home/me/.pyenv/versions/3.9.7/lib/python3.9/site-packages/plotnine/ggplot.py", line 272, in draw
self._build()
File "/home/me/.pyenv/versions/3.9.7/lib/python3.9/site-packages/plotnine/ggplot.py", line 362, in _build
layers.compute_aesthetics(self)
File "/home/me/.pyenv/versions/3.9.7/lib/python3.9/site-packages/plotnine/layer.py", line 457, in compute_aesthetics
l.compute_aesthetics(plot)
File "/home/me/.pyenv/versions/3.9.7/lib/python3.9/site-packages/plotnine/layer.py", line 262, in compute_aesthetics
plot.scales.add_defaults(evaled, evaled_aes)
File "/home/me/.pyenv/versions/3.9.7/lib/python3.9/site-packages/plotnine/scales/scales.py", line 284, in add_defaults
sc = make_scale(scale_var, data[col])
File "/home/me/.pyenv/versions/3.9.7/lib/python3.9/site-packages/plotnine/scales/scales.py", line 351, in make_scale
return scale_klass(*args, **kwargs)
File "/home/me/.pyenv/versions/3.9.7/lib/python3.9/site-packages/plotnine/scales/scale_color.py", line 57, in __init__
self._palette = hue_pal(h, l, s, color_space=color_space)
TypeError: hue_pal() takes no arguments
Code:
import pandas as pd
import numpy as np
from plotnine import (
ggplot,
aes,
geom_path,
geom_point,
geom_col,
scale_color_discrete,
guides,
guide_legend,
)
n = 10
df = pd.DataFrame(
{
"x": np.arange(n),
"y": np.arange(n),
"yfit": np.arange(n) + np.tile([-0.2, 0.2], n // 2),
"cat": ["a", "b"] * (n // 2),
}
)
p = (
ggplot(df)
+ geom_col(aes("x", "y", fill="cat"))
+ geom_point(aes("x", y="yfit", color="cat"))
+ geom_path(aes("x", y="yfit", color="cat"))
)
p.show()
Here is the output from pip freeze:
ansi2html==1.9.2
appdirs==1.4.4
arcticdb==4.5.0
attrs==24.2.0
blinker==1.8.2
certifi==2024.8.30
cffi==1.17.1
charset-normalizer==3.3.2
click==8.1.7
contourpy==1.3.0
cramjam==2.8.3
cycler==0.12.1
duckdb==1.0.0
duckdb_engine==0.13.2
fastparquet==2024.5.0
Flask==3.0.3
Flask-Markdown==0.3
Flask-Misaka==1.0.1
Flask-WTF==1.2.1
fonttools==4.53.1
fsspec==2024.9.0
greenlet==3.0.3
idna==3.8
iex-parser==1.7.0
importlib_metadata==8.4.0
importlib_resources==6.4.4
itsdangerous==2.2.0
Jinja2==3.1.4
joblib==1.4.2
kiwisolver==1.4.7
lark==1.2.2
Markdown==3.7
MarkupSafe==2.1.5
matplotlib==3.9.2
misaka==2.1.1
mizani==0.11.4
monetdbe==0.11
mplfinance==0.12.10b0
msgpack==1.0.8
numpy==1.26.4
packaging==24.1
pandas==2.2.2
patsy==0.5.6
pillow==10.4.0
plotnine==0.13.6
polars==1.7.0
protobuf==5.28.0
py_lets_be_rational==1.0.1
py_vollib==1.0.1
pyarrow==17.0.0
Pycco==0.6.0
pycparser==2.22
pyee==11.1.1
Pygments==2.18.0
pymonetdb==1.8.2
pyparsing==3.1.4
pyppeteer==2.0.0
pyreadr==0.5.2
pystache==0.6.5
python-dateutil==2.9.0.post0
pytz==2024.1
PyYAML==6.0.2
requests==2.32.3
scapy==2.5.0
scikit-learn==1.5.2
scipy==1.13.1
simplejson==3.19.3
six==1.16.0
smartypants==2.0.1
SQLAlchemy==2.0.34
sqlalchemy_monetdb==1.0.0
statsmodels==0.14.2
TA-Lib==0.4.32
threadpoolctl==3.5.0
tqdm==4.66.5
tulipy==0.4.0
typing_extensions==4.12.2
tzdata==2024.1
urllib3==1.26.20
websockets==10.4
Werkzeug==3.0.4
wget==3.2
WTForms==3.1.2
zipp==3.20.1
I get this error when setting color (using the example from the documentation, see below):
Code:
Here is the output from pip freeze: