Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature request: export Position ggproto classes and fallbacks for missing parameters #97

Open
teunbrand opened this issue Sep 20, 2024 · 0 comments

Comments

@teunbrand
Copy link

Hi there,

I think it could be convenient to export the PositionBeeswarm and PositionQuasirandom classes.
This would make it convenient to use a simple position = "beeswarm" in a layer, rather than having to type out position = position_beeswarm() in full.

library(ggbeeswarm)
#> Loading required package: ggplot2

ggplot(mpg, aes(drv, displ)) +
  geom_point(position = "beeswarm")
#> Error in `geom_point()`:
#> ! Can't find position called "beeswarm".

# What it should look like
ggplot(mpg, aes(drv, displ)) +
  geom_point(position = position_beeswarm())

In addition to exporting the position classes, it would be nice if they have nice pre-populated parameters.
In the example below, we cannot use position = "beeswarm" because there is no default method parameter.

# Simulate export of class
PositionBeeswarm <- ggbeeswarm:::PositionBeeswarm

ggplot(mpg, aes(drv, displ)) +
  geom_point(position = "beeswarm")
#> Error in `geom_point()`:
#> ! Problem while computing position.
#> ℹ Error occurred in the 1st layer.
#> Caused by error in `if (method %in% c("swarm", "compactswarm")) ...`:
#> ! argument is of length zero

Created on 2024-09-20 with reprex v2.1.1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant