-
Notifications
You must be signed in to change notification settings - Fork 2.1k
More aesthetics for geom_label()
#5454
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
Changes from 3 commits
2a3b1a6
44297f7
a20925e
49b303e
17b67e9
3002125
e85b646
95fa35e
fe65bdd
2c9300f
d427ea4
aac7112
1a8d145
4372d99
6337d66
4ac30bc
844a028
d0b4bb5
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,7 +2,7 @@ | |
#' @rdname geom_text | ||
#' @param label.padding Amount of padding around label. Defaults to 0.25 lines. | ||
#' @param label.r Radius of rounded corners. Defaults to 0.15 lines. | ||
#' @param label.size Size of label border, in mm. | ||
#' @param label.size `r lifecycle::badge("deprecated")` Please use `linewidth`. Size of label border, in mm. | ||
geom_label <- function(mapping = NULL, data = NULL, | ||
stat = "identity", position = "identity", | ||
..., | ||
|
@@ -27,6 +27,10 @@ geom_label <- function(mapping = NULL, data = NULL, | |
position <- position_nudge(nudge_x, nudge_y) | ||
} | ||
|
||
if (!missing(label.size)) { | ||
message("`label.size` is deprecated. Please use `linewidth` in the future.") | ||
} | ||
|
||
layer( | ||
data = data, | ||
mapping = mapping, | ||
|
@@ -58,15 +62,17 @@ GeomLabel <- ggproto("GeomLabel", Geom, | |
default_aes = aes( | ||
colour = "black", fill = "white", size = 3.88, angle = 0, | ||
hjust = 0.5, vjust = 0.5, alpha = NA, family = "", fontface = 1, | ||
lineheight = 1.2 | ||
lineheight = 1.2, linetype = "solid", linewidth = 0.25 | ||
steveharoz marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
), | ||
|
||
draw_panel = function(self, data, panel_params, coord, parse = FALSE, | ||
na.rm = FALSE, | ||
label.padding = unit(0.25, "lines"), | ||
label.r = unit(0.15, "lines"), | ||
label.size = 0.25, | ||
steveharoz marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
size.unit = "mm") { | ||
size.unit = "mm", | ||
border_colour = NULL, | ||
border_color = border_colour) { | ||
|
||
lab <- data$label | ||
if (parse) { | ||
lab <- parse_safe(as.character(lab)) | ||
|
@@ -102,9 +108,10 @@ GeomLabel <- ggproto("GeomLabel", Geom, | |
lineheight = row$lineheight | ||
), | ||
rect.gp = gpar( | ||
col = if (isTRUE(all.equal(label.size, 0))) NA else row$colour, | ||
col = ifelse(row$linewidth == 0, NA, border_colour %||% border_color %||% row$colour), | ||
fill = alpha(row$fill, row$alpha), | ||
lwd = label.size * .pt | ||
lty = row$linetype, | ||
lwd = (row$linewidth %||% label.size) * .pt | ||
steveharoz marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
) | ||
) | ||
}) | ||
|
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Uh oh!
There was an error while loading. Please reload this page.