Skip to content

Commit 03ead2b

Browse files
committed
proof-of-principle hack
getting geom default from themes
1 parent 4a684f0 commit 03ead2b

File tree

4 files changed

+8
-5
lines changed

4 files changed

+8
-5
lines changed

R/geom-.r

+4-1
Original file line numberDiff line numberDiff line change
@@ -67,12 +67,15 @@ Geom <- ggproto("Geom",
6767
)
6868
},
6969

70-
draw_layer = function(self, data, params, layout, coord) {
70+
draw_layer = function(self, data, params, layout, coord, th) {
7171
if (empty(data)) {
7272
n <- if (is.factor(data$PANEL)) nlevels(data$PANEL) else 1L
7373
return(rep(list(zeroGrob()), n))
7474
}
7575

76+
# whereby complex values measure up to the real world and collapse
77+
if(is.complex(data$colour)) data$colour <- th$plot.title$colour
78+
7679
# Trim off extra parameters
7780
params <- params[intersect(names(params), self$parameters())]
7881

R/geom-text.r

+1-1
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ GeomText <- ggproto("GeomText", Geom,
164164
required_aes = c("x", "y", "label"),
165165

166166
default_aes = aes(
167-
colour = "black", size = 3.88, angle = 0, hjust = 0.5,
167+
colour = 1i, size = 3.88, angle = 0, hjust = 0.5,
168168
vjust = 0.5, alpha = NA, family = "", fontface = 1, lineheight = 1.2
169169
),
170170

R/layer.r

+2-2
Original file line numberDiff line numberDiff line change
@@ -301,14 +301,14 @@ Layer <- ggproto("Layer", NULL,
301301
self$stat$finish_layer(data, self$stat_params)
302302
},
303303

304-
draw_geom = function(self, data, layout, coord) {
304+
draw_geom = function(self, data, layout, coord, th) {
305305
if (empty(data)) {
306306
n <- nrow(layout$panel_layout)
307307
return(rep(list(zeroGrob()), n))
308308
}
309309

310310
data <- self$geom$handle_na(data, self$geom_params)
311-
self$geom$draw_layer(data, self$geom_params, layout, coord)
311+
self$geom$draw_layer(data, self$geom_params, layout, coord, th)
312312
}
313313
)
314314

R/plot-build.r

+1-1
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ ggplot_gtable <- function(data) {
147147
data <- data$data
148148
theme <- plot_theme(plot)
149149

150-
geom_grobs <- Map(function(l, d) l$draw_geom(d, layout, plot$coordinates),
150+
geom_grobs <- Map(function(l, d) l$draw_geom(d, layout, plot$coordinates, th = theme),
151151
plot$layers, data)
152152

153153
plot_table <- layout$render(geom_grobs, data, plot$coordinates, theme, plot$labels)

0 commit comments

Comments
 (0)