Browse files

themes: Make plot.background work

  • Loading branch information...
1 parent fdce876 commit 58a01143830f4300d4128a780a34b5f6170c9bc5 @wch wch committed Aug 1, 2012
Showing with 9 additions and 2 deletions.
  1. +2 −2 R/plot-render.r
  2. +7 −0 visual_test/themes.r
View
4 R/plot-render.r
@@ -149,9 +149,9 @@ ggplot_gtable <- function(data) {
plot_table <- gtable_add_rows(plot_table, theme$plot.margin[3])
plot_table <- gtable_add_cols(plot_table, theme$plot.margin[4], pos = 0)
- if (inherits(theme$plot.background, "theme")) {
+ if (inherits(theme$plot.background, "element")) {
plot_table <- gtable_add_grob(plot_table,
- theme_render(theme, "plot.background", vp = "background"),
+ element_render(theme, "plot.background"),
t = 1, l = 1, b = -1, r = -1, name = "background", z = -Inf)
plot_table$layout <- plot_table$layout[c(nrow(plot_table$layout), 1:(nrow(plot_table$layout) - 1)),]
plot_table$grobs <- plot_table$grobs[c(nrow(plot_table$layout), 1:(nrow(plot_table$layout) - 1))]
View
7 visual_test/themes.r
@@ -66,4 +66,11 @@ p + t
save_vtest("text is element_blank - result is no text")
+# Testing specific elements
+p + theme(axis.text = element_blank(), axis.ticks = element_blank(),
+ axis.title = element_blank(), axis.ticks.margin = unit(0, "cm"),
+ plot.background = element_rect(fill = "lightblue"),
+ panel.border = element_rect(colour = "black", size = 4, fill = NA))
+save_vtest("many blank items, and light blue plot background")
+
end_vcontext()

0 comments on commit 58a0114

Please sign in to comment.