Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Ignore calculated aesthetics that match specified aesthestics
After tidyverse/ggplot2@10fa0014, it's possible for calculated aes to exist for all default_aes
  • Loading branch information
cpsievert committed Nov 7, 2019
commit 27db11e278ce92bef7ec9a4c8be5ee3b3078c9e1
8 changes: 5 additions & 3 deletions R/layers2traces.R
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,14 @@ layers2traces <- function(data, prestats_data, layout, p) {
position = ggtype(y, "position")
)

# add on plot-level mappings, if they're inherited
map <- c(y$mapping, if (isTRUE(y$inherit.aes)) p$mapping)

# consider "calculated" aesthetics (e.g., density, count, etc)
calc_aes <- y$stat$default_aes[ggfun("is_calculated_aes")(y$stat$default_aes)]
map <- c(y$mapping, calc_aes)
calc_aes <- calc_aes[!names(calc_aes) %in% names(map)]

# add on plot-level mappings, if they're inherited
if (isTRUE(y$inherit.aes)) map <- c(map, p$mapping)
map <- c(calc_aes, map)

# turn symbol (e.g., ..count..) & call (e.g. calc(count)) mappings into text labels
map <- ggfun("make_labels")(map)
Expand Down