Skip to content

Commit

Permalink
themes: Make plot.background work
Browse files Browse the repository at this point in the history
  • Loading branch information
wch committed Aug 1, 2012
1 parent fdce876 commit 58a0114
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
4 changes: 2 additions & 2 deletions R/plot-render.r
Expand Up @@ -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))]
Expand Down
7 changes: 7 additions & 0 deletions visual_test/themes.r
Expand Up @@ -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.