Skip to content

How to avoid warnings when adding a secondary axis without breaks or labels in ggplot2 3.5.0? #5713

Closed
@IndrajeetPatil

Description

@IndrajeetPatil

Prior to this release, I could use the secondary axis only to display an additional label, and not include breaks or labels. To do so, I could do the following, but, as can be seen, warnings are generated, and I would like to avoid these warnings since the users of my package will also see these warnings.


library(ggplot2)

ggplot(mtcars, aes(wt, mpg)) +
  geom_point() +
  scale_y_continuous(sec.axis = dup_axis(name = "my secondary axis", breaks = NULL)) 
#> Warning in min(x): no non-missing arguments to min; returning Inf
#> Warning in max(x): no non-missing arguments to max; returning -Inf

ggplot(mtcars, aes(wt, mpg)) +
  geom_point() +
  scale_y_continuous(sec.axis = sec_axis(transform = I, name = "my secondary axis", breaks = NULL)) 
#> Warning in min(x): no non-missing arguments to min; returning Inf

#> Warning in min(x): no non-missing arguments to max; returning -Inf

Created on 2024-02-27 with reprex v2.1.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugan unexpected problem or unintended behavior

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions