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

Fix formals of compute_layer() #3244

Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 3 additions & 0 deletions NEWS.md
Expand Up @@ -121,6 +121,9 @@ core developer team.

* `sec_axis()` now accepts functions as well as formulas (@yutannihilation, #3031).

* `Stat$compute_layer()` and `Position$compute_layer()` now have the same names of
arguments (@yutannihilation, #3202).
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I feel something is missing here. "have now the same names of arguments as other compute_layer() functions"?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks. I should probably say something like "The arguments of Stat*$compute_layer() and Position*$compute_layer() are now renamed to match the ones of Stat$compute_layer() and Position$compute_layer()." Does this make sense...?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, maybe with this edit: "...now renamed to always match the ones...". After all, they mostly were matching already, but not always.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Got it!


# ggplot2 3.1.0

## Breaking changes
Expand Down
2 changes: 1 addition & 1 deletion R/position-identity.r
Expand Up @@ -11,7 +11,7 @@ position_identity <- function() {
#' @usage NULL
#' @export
PositionIdentity <- ggproto("PositionIdentity", Position,
compute_layer = function(data, params, scales) {
compute_layer = function(self, data, params, layout) {
data
}
)
2 changes: 1 addition & 1 deletion R/position-jitter.r
Expand Up @@ -72,7 +72,7 @@ PositionJitter <- ggproto("PositionJitter", Position,
)
},

compute_layer = function(data, params, panel) {
compute_layer = function(self, data, params, layout) {
trans_x <- if (params$width > 0) function(x) jitter(x, amount = params$width)
trans_y <- if (params$height > 0) function(x) jitter(x, amount = params$height)

Expand Down
2 changes: 1 addition & 1 deletion R/position-nudge.R
Expand Up @@ -45,7 +45,7 @@ PositionNudge <- ggproto("PositionNudge", Position,
list(x = self$x, y = self$y)
},

compute_layer = function(data, params, panel) {
compute_layer = function(self, data, params, layout) {
# transform only the dimensions for which non-zero nudging is requested
if (any(params$x != 0)) {
if (any(params$y != 0)) {
Expand Down
4 changes: 2 additions & 2 deletions R/stat-bindot.r
Expand Up @@ -14,13 +14,13 @@ StatBindot <- ggproto("StatBindot", Stat,
params
},

compute_layer = function(self, data, params, panels) {
compute_layer = function(self, data, params, layout) {
data <- remove_missing(data, params$na.rm,
params$binaxis,
snake_class(self),
finite = TRUE
)
ggproto_parent(Stat, self)$compute_layer(data, params, panels)
ggproto_parent(Stat, self)$compute_layer(data, params, layout)
},

compute_panel = function(self, data, scales, na.rm = FALSE, binwidth = NULL,
Expand Down
2 changes: 1 addition & 1 deletion R/stat-identity.r
Expand Up @@ -33,7 +33,7 @@ stat_identity <- function(mapping = NULL, data = NULL,
#' @usage NULL
#' @export
StatIdentity <- ggproto("StatIdentity", Stat,
compute_layer = function(data, scales, params) {
compute_layer = function(self, data, params, layout) {
data
}
)