How to place divisions between facet grid lines

2019-06-21 16:23发布

I'm using ggplot with facet_grid to make a plot for publication. I'm not sure how the reviewers will react to the standard gray background with white grid lines and so I'm preparing with and without. However when I use opts(panel.background = theme_blank()) the display lacks the between panes discrimination that the standard background gives. what is the easiest way to add the between pane grid back (not that it was there but it was white against gray) that looks similar to my desired outcome below?

The Code

ggplot(CO2, aes(conc)) + geom_density() + 
    facet_grid(Type~Treatment) +
    opts(panel.background = theme_blank())

Current Outcome enter image description here

Desired Outcome

enter image description here

Thank you in advance.

标签: r ggplot2
1条回答
看我几分像从前
2楼-- · 2019-06-21 16:32

This should do:

last_plot() + theme_bw()

or

last_plot() + 
   opts(panel.background = theme_rect(fill = NA, color = "black"))

Since version 0.9.2, opts has been replaced by theme:

last_plot() + 
   theme(panel.background = element_rect(fill = NA, color = "black"))
查看更多
登录 后发表回答