Skip to content
Merged
Show file tree
Hide file tree
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
3 changes: 3 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@
* Improved error with hint when piping a `ggplot` object into a facet function
(#4379, @mitchelloharawild).

* Fix a bug that `after_stat()` and `after_scale()` cannot refer to aesthetics
if it's specified in the plot-global mapping (@yutannihilation, #4260).

# ggplot2 3.3.3
This is a small patch release mainly intended to address changes in R and CRAN.
It further changes the licensing model of ggplot2 to an MIT license.
Expand Down
17 changes: 8 additions & 9 deletions R/layer.r
Original file line number Diff line number Diff line change
Expand Up @@ -203,16 +203,18 @@ Layer <- ggproto("Layer", NULL,
# hook to allow a layer access to the final layer data
# in input form and to global plot info
setup_layer = function(self, data, plot) {
# For annotation geoms, it is useful to be able to ignore the default aes
if (isTRUE(self$inherit.aes)) {
self$mapping <- defaults(self$mapping, plot$mapping)
# defaults() strips class, but it needs to be preserved for now
class(self$mapping) <- "uneval"
}

data
},

compute_aesthetics = function(self, data, plot) {
# For annotation geoms, it is useful to be able to ignore the default aes
if (self$inherit.aes) {
aesthetics <- defaults(self$mapping, plot$mapping)
} else {
aesthetics <- self$mapping
}
aesthetics <- self$mapping

# Drop aesthetics that are set or calculated
set <- names(aesthetics) %in% names(self$aes_params)
Expand Down Expand Up @@ -289,9 +291,6 @@ Layer <- ggproto("Layer", NULL,

# Assemble aesthetics from layer, plot and stat mappings
aesthetics <- self$mapping
if (self$inherit.aes) {
aesthetics <- defaults(aesthetics, plot$mapping)
}
aesthetics <- defaults(aesthetics, self$stat$default_aes)
aesthetics <- compact(aesthetics)

Expand Down