Skip to content

Commit 1eff185

Browse files
committed
add colour/fill to element_geom
1 parent 3f67f03 commit 1eff185

File tree

3 files changed

+17
-4
lines changed

3 files changed

+17
-4
lines changed

R/theme-elements.R

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,9 @@ element_geom <- function(
213213
# text
214214
family = NULL, fontsize = NULL,
215215
# points
216-
pointsize = NULL, pointshape = NULL) {
216+
pointsize = NULL, pointshape = NULL,
217+
218+
colour = NULL, color = NULL, fill = NULL) {
217219

218220
if (!is.null(fontsize)) {
219221
fontsize <- fontsize / .pt
@@ -227,7 +229,9 @@ element_geom <- function(
227229
linewidth = linewidth, borderwidth = borderwidth,
228230
linetype = linetype, bordertype = bordertype,
229231
family = family, fontsize = fontsize,
230-
pointsize = pointsize, pointshape = pointshape
232+
pointsize = pointsize, pointshape = pointshape,
233+
colour = color %||% colour,
234+
fill = fill
231235
),
232236
class = c("element_geom", "element")
233237
)
@@ -238,7 +242,8 @@ element_geom <- function(
238242
linewidth = 0.5, borderwidth = 0.5,
239243
linetype = 1L, bordertype = 1L,
240244
family = "", fontsize = 11,
241-
pointsize = 1.5, pointshape = 19
245+
pointsize = 1.5, pointshape = 19,
246+
fill = NULL, colour = NULL
242247
)
243248

244249
#' @export

R/theme.R

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -760,6 +760,11 @@ calc_element <- function(element, theme, verbose = FALSE, skip_blank = FALSE,
760760
# if we have null properties, try to fill in from ggplot_global$theme_default
761761
el_out <- combine_elements(el_out, ggplot_global$theme_default[[element]])
762762
nullprops <- vapply(el_out, is.null, logical(1))
763+
if (inherits(el_out, "element_geom")) {
764+
# Geom elements are expected to have NULL fill/colour, so allow these
765+
# to be missing
766+
nullprops[c("colour", "fill")] <- FALSE
767+
}
763768
if (!any(nullprops)) {
764769
return(el_out) # no null properties remaining, return element
765770
}

man/element.Rd

Lines changed: 4 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)