Skip to content

fix wrong parameters due to partial matching #6410

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

Closed
wants to merge 2 commits into from
Closed
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
2 changes: 2 additions & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# Generated by roxygen2: do not edit by hand

S3method("$",ggplot2_parameters)
S3method("$",ggproto)
S3method("$",ggproto_parent)
S3method("$",theme)
Expand All @@ -9,6 +10,7 @@ S3method("[",mapped_discrete)
S3method("[",uneval)
S3method("[<-",mapped_discrete)
S3method("[<-",uneval)
S3method("[[",ggplot2_parameters)
S3method("[[",ggproto)
S3method("[[<-",uneval)
S3method(.DollarNames,ggproto)
Expand Down
4 changes: 2 additions & 2 deletions R/facet-.R
Original file line number Diff line number Diff line change
Expand Up @@ -879,7 +879,7 @@
return(vec_cbind(data %|W|% NULL, PANEL = integer(0)))
}

vars <- params$facet %||% c(params$rows, params$cols)
vars <- params$facets %||% c(params$rows, params$cols)

Check warning on line 882 in R/facet-.R

View check run for this annotation

Codecov / codecov/patch

R/facet-.R#L882

Added line #L882 was not covered by tests

if (length(vars) == 0) {
data$PANEL <- layout$PANEL
Expand All @@ -898,7 +898,7 @@
# Compute faceting values
facet_vals <- eval_facets(vars, data, params$.possible_columns)

include_margins <- !isFALSE(params$margin %||% FALSE) &&
include_margins <- !isFALSE(params$margins %||% FALSE) &&

Check warning on line 901 in R/facet-.R

View check run for this annotation

Codecov / codecov/patch

R/facet-.R#L901

Added line #L901 was not covered by tests
nrow(facet_vals) == nrow(data) && grid_layout
if (include_margins) {
# Margins are computed on evaluated faceting values (#1864).
Expand Down
2 changes: 1 addition & 1 deletion R/labels.R
Original file line number Diff line number Diff line change
Expand Up @@ -351,7 +351,7 @@ get_alt_text.gtable <- function(p, ...) {
#'
generate_alt_text <- function(p) {
# Combine titles
if (!is.null(p$label$title %||% p$labels$subtitle)) {
if (!is.null(p$labels$title %||% p$labels$subtitle)) {
title <- sub("\\.?$", "", c(p$labels$title, p$labels$subtitle))
if (length(title) == 2) {
title <- paste0(title[1], ": ", title[2])
Expand Down
10 changes: 10 additions & 0 deletions R/layer.R
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,9 @@
params <- rename_aes(params)
aes_params <- params[intersect(names(params), union(geom$aesthetics(), position$aesthetics()))]
geom_params <- params[intersect(names(params), geom$parameters(TRUE))]
geom_params <- new_params(geom_params)
stat_params <- params[intersect(names(params), stat$parameters(TRUE))]
stat_params <- new_params(stat_params)

ignore <- c("key_glyph", "name", "layout")
all <- c(geom$parameters(TRUE), stat$parameters(TRUE), geom$aesthetics(), position$aesthetics(), ignore)
Expand Down Expand Up @@ -543,3 +545,11 @@
data[failed] <- NULL
data
}

new_params <- function(params) structure(params, class = "ggplot2_parameters")

#' @export
`$.ggplot2_parameters` <- function(x, i) .subset2(x, i)

#' @export
`[[.ggplot2_parameters` <- function(x, i) .subset2(x, i)

Check warning on line 555 in R/layer.R

View check run for this annotation

Codecov / codecov/patch

R/layer.R#L555

Added line #L555 was not covered by tests
2 changes: 1 addition & 1 deletion tests/testthat/test-legend-draw.R
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ test_that("all keys can be drawn without 'params'", {
expect_in(nse, names(keys))

# Add title to every key
template <- gtable(width = unit(size, "mm"), heights = unit(c(1, size), c("lines", "mm")))
template <- gtable(widths = unit(size, "mm"), heights = unit(c(1, size), c("lines", "mm")))
keys <- Map(
function(key, name) {
text <- textGrob(name, gp = gpar(fontsize = 8))
Expand Down
Loading