has2k1 / plotnine

A Grammar of Graphics for Python
https://plotnine.org
MIT License
3.92k stars 210 forks source link

Using (plot) values as color in aes returns an error #710

Closed laurentiush closed 11 months ago

laurentiush commented 11 months ago

The following example taken from the documentation fails:

df = pd.DataFrame({
    'col1': np.arange(11),
    'col2': np.arange(11)
})

(ggplot(df, aes('col1', 'np.square(col2)', color='col2'))
 + geom_point(size=3)
)

with the following error:

TypeError: cmap_pal.__init__() takes 2 positional arguments but 3 were given

see https://plotnine.readthedocs.io/en/stable/generated/plotnine.mapping.aes.html#plotnine.mapping.aes for the example.

has2k1 commented 11 months ago

Make sure plotnine and mizani packages have compatible versions.

pip install "plotnine==0.12.2"
pip install "mizani<0.10.0"