Skip to content

geom_point() integer shapes throw ValueError #1016

@markjrieke-fortisgames

Description

@markjrieke-fortisgames

Howdy! As a previous R user, plotnine is a wonderful port of ggplot2. It looks like I ran into either a bug or out-of-date documentation --- supplying an integer to geom_point()'s shape argument throws a ValueError, despite being documented as having shapes.

import polars as pl
import plotnine as gg # 0.15.1

plot = (
    pl.DataFrame({
        'x': [1, 2, 3],
        'y': [1, 2, 3]
    })
    >>
    gg.ggplot(gg.aes(
        x='x',
        y='y'
    ))
)

The string-based shapes work as expected, including the "numbers as strings" shapes:

# characters work as expected
(plot + gg.geom_point(size=3, shape='D')).show()

# numbers as characters work as expected
(plot + gg.geom_point(size=3, shape='1')).show()

The integer-based shapes, however, don't seem to cooperate:

# Yields a ValueError: Unrecognized marker style np.int64(7)
(plot + gg.geom_point(size=3, shape=7)).show()

As an aside, I ran into this when trying to create an unfilled circle (shape=21 in R's ggplot2). Is there a way to do this in plotnine? My first assumption (supplying fill=None) still yields a filled circle with the default shape:

(plot + gg.geom_point(size=3, fill=None)).show()

If this latter piece should move to a new issue as a feature request, please let me know!

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions