Skip to content

Rename ggpar() to gg_par() #5899

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 2 commits into from
May 24, 2024
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
2 changes: 1 addition & 1 deletion NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -429,7 +429,7 @@ export(get_layer_grob)
export(get_panel_scales)
export(get_theme)
export(gg_dep)
export(ggpar)
export(gg_par)
export(ggplot)
export(ggplotGrob)
export(ggplot_add)
Expand Down
2 changes: 1 addition & 1 deletion NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@
(@teunbrand, #5756).
* Fixed bug in `guide_custom()` that would throw error with `theme_void()`
(@teunbrand, #5856).
* New helper function `ggpar()` to translate ggplot2's interpretation of
* New helper function `gg_par()` to translate ggplot2's interpretation of
graphical parameters to {grid}'s interpretation (@teunbrand, #5866).
* `scale_{x/y}_discrete()` can now accept a `sec.axis`. It is recommended to
only use `dup_axis()` to set custom breaks or labels, as discrete variables
Expand Down
8 changes: 4 additions & 4 deletions R/annotation-logticks.R
Original file line number Diff line number Diff line change
Expand Up @@ -175,14 +175,14 @@ GeomLogticks <- ggproto("GeomLogticks", Geom,
ticks$x_b <- with(data, segmentsGrob(
x0 = unit(xticks$x, "native"), x1 = unit(xticks$x, "native"),
y0 = unit(xticks$start, "cm"), y1 = unit(xticks$end, "cm"),
gp = ggpar(col = alpha(colour, alpha), lty = linetype, lwd = linewidth)
gp = gg_par(col = alpha(colour, alpha), lty = linetype, lwd = linewidth)
))
}
if (grepl("t", sides) && nrow(xticks) > 0) {
ticks$x_t <- with(data, segmentsGrob(
x0 = unit(xticks$x, "native"), x1 = unit(xticks$x, "native"),
y0 = unit(1, "npc") - unit(xticks$start, "cm"), y1 = unit(1, "npc") - unit(xticks$end, "cm"),
gp = ggpar(col = alpha(colour, alpha), lty = linetype, lwd = linewidth)
gp = gg_par(col = alpha(colour, alpha), lty = linetype, lwd = linewidth)
))
}
}
Expand Down Expand Up @@ -213,14 +213,14 @@ GeomLogticks <- ggproto("GeomLogticks", Geom,
ticks$y_l <- with(data, segmentsGrob(
y0 = unit(yticks$y, "native"), y1 = unit(yticks$y, "native"),
x0 = unit(yticks$start, "cm"), x1 = unit(yticks$end, "cm"),
gp = ggpar(col = alpha(colour, alpha), lty = linetype, lwd = linewidth)
gp = gg_par(col = alpha(colour, alpha), lty = linetype, lwd = linewidth)
))
}
if (grepl("r", sides) && nrow(yticks) > 0) {
ticks$y_r <- with(data, segmentsGrob(
y0 = unit(yticks$y, "native"), y1 = unit(yticks$y, "native"),
x0 = unit(1, "npc") - unit(yticks$start, "cm"), x1 = unit(1, "npc") - unit(yticks$end, "cm"),
gp = ggpar(col = alpha(colour, alpha), lty = linetype, lwd = linewidth)
gp = gg_par(col = alpha(colour, alpha), lty = linetype, lwd = linewidth)
))
}
}
Expand Down
2 changes: 1 addition & 1 deletion R/annotation-map.R
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ GeomAnnotationMap <- ggproto("GeomAnnotationMap", GeomMap,

polygonGrob(coords$x, coords$y, default.units = "native",
id = grob_id,
gp = ggpar(
gp = gg_par(
col = data$colour, fill = alpha(data$fill, data$alpha),
lwd = data$linewidth)
)
Expand Down
2 changes: 1 addition & 1 deletion R/coord-radial.R
Original file line number Diff line number Diff line change
Expand Up @@ -326,7 +326,7 @@ CoordRadial <- ggproto("CoordRadial", Coord,
y = c(Inf, -Inf, -Inf, Inf)
)
background <- coord_munch(self, background, panel_params, is_closed = TRUE)
bg_gp <- ggpar(
bg_gp <- gg_par(
lwd = bg_element$linewidth,
col = bg_element$colour, fill = bg_element$fill,
lty = bg_element$linetype
Expand Down
2 changes: 1 addition & 1 deletion R/coord-sf.R
Original file line number Diff line number Diff line change
Expand Up @@ -335,7 +335,7 @@ CoordSf <- ggproto("CoordSf", CoordCartesian,
if (inherits(el, "element_blank")) {
grobs <- list(element_render(theme, "panel.background"))
} else {
line_gp <- ggpar(
line_gp <- gg_par(
col = el$colour,
lwd = el$linewidth,
lty = el$linetype
Expand Down
2 changes: 1 addition & 1 deletion R/geom-curve.R
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ GeomCurve <- ggproto("GeomCurve", GeomSegment,
default.units = "native",
curvature = curvature, angle = angle, ncp = ncp,
square = FALSE, squareShape = 1, inflect = FALSE, open = TRUE,
gp = ggpar(
gp = gg_par(
col = alpha(trans$colour, trans$alpha),
fill = alpha(arrow.fill, trans$alpha),
lwd = trans$linewidth,
Expand Down
8 changes: 4 additions & 4 deletions R/geom-dotplot.R
Original file line number Diff line number Diff line change
Expand Up @@ -293,10 +293,10 @@ GeomDotplot <- ggproto("GeomDotplot", Geom,
dotstackGrob(stackaxis = stackaxis, x = tdata$x, y = tdata$y, dotdia = dotdianpc,
stackposition = tdata$stackpos, stackdir = stackdir, stackratio = stackratio,
default.units = "npc",
gp = ggpar(col = alpha(tdata$colour, tdata$alpha),
fill = fill_alpha(tdata$fill, tdata$alpha),
lwd = tdata$stroke / .pt, lty = tdata$linetype,
lineend = lineend))
gp = gg_par(col = alpha(tdata$colour, tdata$alpha),
fill = fill_alpha(tdata$fill, tdata$alpha),
lwd = tdata$stroke / .pt, lty = tdata$linetype,
lineend = lineend))
)
},

Expand Down
2 changes: 1 addition & 1 deletion R/geom-hex.R
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ GeomHex <- ggproto("GeomHex", Geom,

ggname("geom_hex", polygonGrob(
coords$x, coords$y,
gp = ggpar(
gp = gg_par(
col = data$colour,
fill = fill_alpha(data$fill, data$alpha),
lwd = data$linewidth,
Expand Down
8 changes: 4 additions & 4 deletions R/geom-label.R
Original file line number Diff line number Diff line change
Expand Up @@ -90,14 +90,14 @@ GeomLabel <- ggproto("GeomLabel", Geom,
padding = label.padding,
r = label.r,
angle = row$angle,
text.gp = ggpar(
text.gp = gg_par(
col = row$colour,
fontsize = row$size * size.unit,
fontfamily = row$family,
fontface = row$fontface,
lineheight = row$lineheight
),
rect.gp = ggpar(
rect.gp = gg_par(
col = if (isTRUE(all.equal(label.size, 0))) NA else row$colour,
fill = fill_alpha(row$fill, row$alpha),
lwd = label.size
Expand All @@ -115,7 +115,7 @@ GeomLabel <- ggproto("GeomLabel", Geom,
labelGrob <- function(label, x = unit(0.5, "npc"), y = unit(0.5, "npc"),
just = "center", padding = unit(0.25, "lines"), r = unit(0.1, "snpc"),
angle = NULL, default.units = "npc", name = NULL,
text.gp = gpar(), rect.gp = ggpar(fill = "white"), vp = NULL) {
text.gp = gpar(), rect.gp = gg_par(fill = "white"), vp = NULL) {

if (length(label) != 1) {
cli::cli_abort("{.arg label} must be of length 1.")
Expand All @@ -130,7 +130,7 @@ labelGrob <- function(label, x = unit(0.5, "npc"), y = unit(0.5, "npc"),
vp <- viewport(
angle = angle, x = x, y = y,
width = unit(0, "cm"), height = unit(0, "cm"),
gp = ggpar(fontsize = text.gp$fontsize)
gp = gg_par(fontsize = text.gp$fontsize)
)
x <- unit(rep(0.5, length(x)), "npc")
y <- unit(rep(0.5, length(y)), "npc")
Expand Down
2 changes: 1 addition & 1 deletion R/geom-map.R
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ GeomMap <- ggproto("GeomMap", GeomPolygon,
data <- data[data_rows, , drop = FALSE]

polygonGrob(coords$x, coords$y, default.units = "native", id = grob_id,
gp = ggpar(
gp = gg_par(
col = data$colour,
fill = fill_alpha(data$fill, data$alpha),
lwd = data$linewidth,
Expand Down
4 changes: 2 additions & 2 deletions R/geom-path.R
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ GeomPath <- ggproto("GeomPath", Geom,
segmentsGrob(
munched$x[!end], munched$y[!end], munched$x[!start], munched$y[!start],
default.units = "native", arrow = arrow,
gp = ggpar(
gp = gg_par(
col = alpha(munched$colour, munched$alpha)[!end],
fill = alpha(munched$fill, munched$alpha)[!end],
lwd = munched$linewidth[!end],
Expand All @@ -221,7 +221,7 @@ GeomPath <- ggproto("GeomPath", Geom,
polylineGrob(
munched$x, munched$y, id = id,
default.units = "native", arrow = arrow,
gp = ggpar(
gp = gg_par(
col = alpha(munched$colour, munched$alpha)[start],
fill = alpha(munched$fill, munched$alpha)[start],
lwd = munched$linewidth[start],
Expand Down
2 changes: 1 addition & 1 deletion R/geom-point.R
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ GeomPoint <- ggproto("GeomPoint", Geom,
pointsGrob(
coords$x, coords$y,
pch = coords$shape,
gp = ggpar(
gp = gg_par(
col = alpha(coords$colour, coords$alpha),
fill = fill_alpha(coords$fill, coords$alpha),
pointsize = coords$size,
Expand Down
4 changes: 2 additions & 2 deletions R/geom-polygon.R
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ GeomPolygon <- ggproto("GeomPolygon", Geom,
polygonGrob(
munched$x, munched$y, default.units = "native",
id = munched$group,
gp = ggpar(
gp = gg_par(
col = first_rows$colour,
fill = fill_alpha(first_rows$fill, first_rows$alpha),
lwd = first_rows$linewidth,
Expand Down Expand Up @@ -161,7 +161,7 @@ GeomPolygon <- ggproto("GeomPolygon", Geom,
munched$x, munched$y, default.units = "native",
id = id, pathId = munched$group,
rule = rule,
gp = ggpar(
gp = gg_par(
col = first_rows$colour,
fill = fill_alpha(first_rows$fill, first_rows$alpha),
lwd = first_rows$linewidth,
Expand Down
2 changes: 1 addition & 1 deletion R/geom-rect.R
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ GeomRect <- ggproto("GeomRect", Geom,
height = coords$ymax - coords$ymin,
default.units = "native",
just = c("left", "top"),
gp = ggpar(
gp = gg_par(
col = coords$colour,
fill = fill_alpha(coords$fill, coords$alpha),
lwd = coords$linewidth,
Expand Down
4 changes: 2 additions & 2 deletions R/geom-ribbon.R
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ GeomRibbon <- ggproto("GeomRibbon", Geom,
g_poly <- polygonGrob(
munched_poly$x, munched_poly$y, id = munched_poly$id,
default.units = "native",
gp = ggpar(
gp = gg_par(
fill = fill_alpha(aes$fill, aes$alpha),
col = if (is_full_outline) aes$colour else NA,
lwd = if (is_full_outline) aes$linewidth else 0,
Expand Down Expand Up @@ -246,7 +246,7 @@ GeomRibbon <- ggproto("GeomRibbon", Geom,
g_lines <- polylineGrob(
munched_lines$x, munched_lines$y, id = munched_lines$id,
default.units = "native",
gp = ggpar(
gp = gg_par(
col = aes$colour,
lwd = aes$linewidth,
lty = aes$linetype,
Expand Down
2 changes: 1 addition & 1 deletion R/geom-rug.R
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ GeomRug <- ggproto("GeomRug", Geom,
list(min = -1 * length, max = unit(1, "npc") + length)
}

gp <- ggpar(
gp <- gg_par(
col = alpha(data$colour, data$alpha),
lty = data$linetype,
lwd = data$linewidth,
Expand Down
2 changes: 1 addition & 1 deletion R/geom-segment.R
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ GeomSegment <- ggproto("GeomSegment", Geom,
arrow.fill <- arrow.fill %||% coord$colour
return(segmentsGrob(coord$x, coord$y, coord$xend, coord$yend,
default.units = "native",
gp = ggpar(
gp = gg_par(
col = alpha(coord$colour, coord$alpha),
fill = alpha(arrow.fill, coord$alpha),
lwd = coord$linewidth,
Expand Down
2 changes: 1 addition & 1 deletion R/geom-text.R
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ GeomText <- ggproto("GeomText", Geom,
data$x, data$y, default.units = "native",
hjust = data$hjust, vjust = data$vjust,
rot = data$angle,
gp = ggpar(
gp = gg_par(
col = alpha(data$colour, data$alpha),
fontsize = data$size * size.unit,
fontfamily = data$family,
Expand Down
4 changes: 2 additions & 2 deletions R/guide-colorbar.R
Original file line number Diff line number Diff line change
Expand Up @@ -379,7 +379,7 @@ GuideColourbar <- ggproto(
vjust = 0, hjust = 0,
width = width, height = height,
default.units = "npc",
gp = ggpar(col = NA, fill = decor$colour)
gp = gg_par(col = NA, fill = decor$colour)
)
} else if (params$display == "gradient") {
check_device("gradients", call = expr(guide_colourbar()))
Expand All @@ -394,7 +394,7 @@ GuideColourbar <- ggproto(
vertical = list(x1 = unit(0.5, "npc"), x2 = unit(0.5, "npc"))
)
gradient <- inject(linearGradient(decor$colour, value, !!!position))
grob <- rectGrob(gp = ggpar(fill = gradient, col = NA))
grob <- rectGrob(gp = gg_par(fill = gradient, col = NA))
}

frame <- element_grob(elements$frame, fill = NA)
Expand Down
2 changes: 1 addition & 1 deletion R/guide-colorsteps.R
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ GuideColoursteps <- ggproto(

size <- abs(decor$max - decor$min)
just <- as.numeric(decor$min > decor$max)
gp <- ggpar(col = NA, fill = decor$colour)
gp <- gg_par(col = NA, fill = decor$colour)
if (params$direction == "vertical") {
grob <- rectGrob(
x = 0, y = decor$min,
Expand Down
Loading
Loading