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

Reconsider the deprecation of the groupOnX argument #82

Closed
TengMCing opened this issue Feb 15, 2023 · 2 comments
Closed

Reconsider the deprecation of the groupOnX argument #82

TengMCing opened this issue Feb 15, 2023 · 2 comments
Labels
bug fixed-in-dev issues that have been resolved but not reflected in CRAN

Comments

@TengMCing
Copy link

When one tries to use the groupOnX argument to specify the grouping behaviour, the current version will give this warning:

The `groupOnX` argument of `geom_quasirandom()` is deprecated as of ggbeeswarm 0.7.1.
i ggplot2 now handles this case automatically.

I have tried many alternative methods to specify the grouping behaviour, but only one works, which is by using the coord_filp() function.

library(tidyverse)
library(ggbeeswarm)
ggplot(bind_rows(cars, cars, cars)) +
  geom_quasirandom(aes(x = dist, y = speed), width = 2) +
  coord_flip()

This loses the flexibility to control the grouping behaviour of a single layer, since coord_flip() will be applied to all layers.

In ggbeeswarm 0.6.0, I can write the following function without worrying about the content of the input plot. But in ggbeeswarm 0.7.1, I haven't found a way to do it.

add_a_quasirandom_layer <- function(p) {
    p <- p + geom_quasirandom(data = <some_data>, aes(<some_aes>), groupOnX = FALSE)
    p
}

I may be wrong about this if there is actually a way to control the per-layer grouping behaviour. However, if it is not possible, could you consider not deprecating the groupOnX argument?

@csdaw
Copy link
Collaborator

csdaw commented Apr 22, 2023

You're right that in v0.7.1 with the removal of groupOnX, its not possible to control on which axis the points are separated without
using coord_flip(). And I understand what you mean by per layer grouping.

However, the example you've given is a bit confusing. Can you provide a different example with v0.6.0 that demonstrates what you would like to do?

Normally, you'd want to jitter points along a categorical axis (regardless of whether the categories are on the x or y axis). But in the example you are comparing two continuous variables (in which case I wouldn't jitter but use alpha instead to preserve the point coordinates).

@eclarke eclarke added fixed-in-dev issues that have been resolved but not reflected in CRAN bug labels Apr 29, 2023
@eclarke
Copy link
Owner

eclarke commented Apr 29, 2023

Hi, after looking at some of the other functions in ggplot2, I've introduced an orientation parameter in v0.7.2 similar to what's used in geom_line and others. Now the main axis (e.g., the axis on which the data is grouped) gets inferred based on the data, but this can be overridden using orientation="x".

Furthermore, the groupOnX parameter remains soft-deprecated, but specifying it will have the same behavior as passing orientation="x". This means you shouldn't have to use coord_flip() now unless you want to for other reasons.

This plus other fixes will be on CRAN soon, or you can try them out by installing from GitHub.

@eclarke eclarke mentioned this issue Apr 29, 2023
eclarke added a commit that referenced this issue Apr 29, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug fixed-in-dev issues that have been resolved but not reflected in CRAN
Projects
None yet
Development

No branches or pull requests

3 participants