Skip to content

Bug: layer(geom = "boxplot",...) produces error #6191

Closed

Description

@davidhodge931

Wondering if it was possible to make the extra args (.e.g. median.colour) added to boxplot could also available via layer?

library(tidyverse)
library(palmerpenguins)

penguins |>
  ggplot(aes(    y = flipper_length_mm,
                 x = species)) +
  geom_boxplot(
    median.colour = "red",
  )
#> Warning: Removed 2 rows containing non-finite outside the scale range
#> (`stat_boxplot()`).

penguins |>
  ggplot(aes(    y = flipper_length_mm,
                 x = species)) +
  layer(
    geom = "boxplot",
    stat = "boxplot", 
    position = "dodge2",
    params = list(median.colour = "red"),
  )
#> Warning: Ignoring unknown parameters: `median.colour`
#> Removed 2 rows containing non-finite outside the scale range
#> (`stat_boxplot()`).

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

Activity

  1. teunbrand commented on Nov 19, 2024

    @teunbrand
    Collaborator

    The answer on whether this is possible is 'yes'.
    My answer on whether this should happen is 'probably not'.
    There are just too many dang arguments to pass around.
    As the one who implemented these, I'm a bit biased of course.
    I'm happy to implement something else if you can get one of the other maintainers on board.

  2. davidhodge931 commented on Nov 19, 2024

    @davidhodge931
    Author

    Ahh, I see..

    Maybe related to this is that layer seem to error for boxplot with a colour/fill aesthetic?

    library(tidyverse)
    library(palmerpenguins)
    
    penguins |>
      ggplot(aes(x = species, y = flipper_length_mm, colour = species)) +
      layer(
        geom = "boxplot",
        stat = "boxplot",
        position = "dodge2",
      )
    #> Warning: Removed 2 rows containing non-finite outside the scale range
    #> (`stat_boxplot()`).
    #> Error in unit(x, default.units): 'x' and 'units' must have length > 0

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

  3. teunbrand commented on Nov 19, 2024

    @teunbrand
    Collaborator

    You're right about that related case and I'm happy to fix that to ensure layer(geom = "boxplot") works

  4. added
    bug
    on Nov 19, 2024
  5. changed the title [-]Could the new boxplot extra features be available through `layer' too?[/-] [+]Bug: `layer(geom = "boxplot",...)' produces error[/+] on Nov 19, 2024
  6. changed the title [-]Bug: `layer(geom = "boxplot",...)' produces error[/-] [+]Bug: `layer(geom = "boxplot",...)` produces error[/+] on Nov 20, 2024
  7. davidhodge931 commented on Nov 20, 2024

    @davidhodge931
    Author

    Do you want to leave this open as issue (or create an issue) that the extra new boxplot params can't be used with layer?

    Or just close for now once the bug bit has been fixed in that it is not that important and can't be done any time soon?

    (My bad for mixing 2 issues)

  8. teunbrand commented on Nov 20, 2024

    @teunbrand
    Collaborator

    the extra new boxplot params can't be used with layer

    They can, but they should be lists of colour/linetype/linewidth parameters, as geom_boxplot() handles them.
    If you'd like to keep this issue open to get a 2nd opinion, that is fine with me.
    If not, I can close it whenever #6192 gets merged.

  9. davidhodge931 commented on Nov 20, 2024

    @davidhodge931
    Author

    Ah, I get it now - nice!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions