Skip to content

Add rename_size = TRUE to GeomBar #4939

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

Merged
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: 2 additions & 1 deletion R/geom-bar.r
Original file line number Diff line number Diff line change
Expand Up @@ -164,5 +164,6 @@ GeomBar <- ggproto("GeomBar", GeomRect,
lineend = lineend,
linejoin = linejoin
)
}
},
rename_size = TRUE
)
46 changes: 2 additions & 44 deletions R/geom-col.r
Original file line number Diff line number Diff line change
Expand Up @@ -31,47 +31,5 @@ geom_col <- function(mapping = NULL, data = NULL,
#' @usage NULL
#' @export
#' @include geom-rect.r
GeomCol <- ggproto("GeomCol", GeomRect,
required_aes = c("x", "y"),

# These aes columns are created by setup_data(). They need to be listed here so
# that GeomRect$handle_na() properly removes any bars that fall outside the defined
# limits, not just those for which x and y are outside the limits
non_missing_aes = c("xmin", "xmax", "ymin", "ymax"),

setup_params = function(data, params) {
params$flipped_aes <- has_flipped_aes(data, params)
params
},

extra_params = c("just", "na.rm", "orientation"),

setup_data = function(data, params) {
data$flipped_aes <- params$flipped_aes
data <- flip_data(data, params$flipped_aes)
data$width <- data$width %||%
params$width %||% (resolution(data$x, FALSE) * 0.9)
data$just <- params$just %||% 0.5
data <- transform(
data,
ymin = pmin(y, 0), ymax = pmax(y, 0),
xmin = x - width * (1 - just), xmax = x + width * just,
width = NULL, just = NULL
)
flip_data(data, params$flipped_aes)
},

draw_panel = function(self, data, panel_params, coord, lineend = "butt",
linejoin = "mitre", width = NULL, flipped_aes = FALSE) {
# Hack to ensure that width is detected as a parameter
ggproto_parent(GeomRect, self)$draw_panel(
data,
panel_params,
coord,
lineend = lineend,
linejoin = linejoin
)
},

rename_size = TRUE
)
# TODO: deprecate this
GeomCol <- ggproto("GeomCol", GeomBar)