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

work with NULL mappings #31

Closed
topepo opened this issue Aug 3, 2021 · 2 comments
Closed

work with NULL mappings #31

topepo opened this issue Aug 3, 2021 · 2 comments
Labels
bug an unexpected problem or unintended behavior

Comments

@topepo
Copy link
Member

topepo commented Aug 3, 2021

The function maybe_modify_mapping() adds a new aesthetic mapping to an existing ggplot object.

There is a bug where, for some autoplot() results, the mapping that we want to modify is NULL:

maybe_modify_mapping <- function(x) {
  has_mapping <- any(names(x) == "mapping")
  is_point <- is_geom_point(x)
  is_null <- identical(x$mapping, NULL).  #<- currently skip null mappings
  if (has_mapping & is_point & !is_null) {
    x$mapping <- utils::modifyList(x$mapping, ggplot2::aes(customdata = .config))
  }
  x
}

If there is a geom_point() with a local NULL mapping, we should make a new mapping with customdata = .config.

@topepo topepo added the bug an unexpected problem or unintended behavior label Aug 3, 2021
@adhikars11
Copy link
Collaborator

Modifying the function to the following solves the issue:

maybe_modify_mapping <- function(x) {
  has_mapping <- any(names(x) == "mapping")
  is_point <- is_geom_point(x)
  if (has_mapping & is_point) {
    x$mapping <- utils::modifyList(
      x$mapping %||% list(),
      ggplot2::aes(customdata = .config)
    )
  }
  x
}

@github-actions
Copy link

This issue has been automatically locked. If you believe you have found a related problem, please file a new issue (with a reprex: https://reprex.tidyverse.org) and link to this issue.

@github-actions github-actions bot locked and limited conversation to collaborators Jan 10, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug an unexpected problem or unintended behavior
Projects
None yet
Development

No branches or pull requests

2 participants