ggplot2中的构面问题(重叠和厚度)

时间:2018-06-28 18:15:36

标签: r ggplot2 graphics themes facet

我对ggplot2的方面有疑问。当我制作小平面的框架的厚度时,它的厚度应该是它的两倍。它与绘图内部轮廓的粗细相加(屏幕快照中的问题2,strip.background和panel.background的大小为1.5)。此外,网格与图的内部边缘重叠(屏幕快照中的问题1)。

Problems with Facets

我为主题编写的代码如下:

majorgridcolor <- "#BBD2DB"
minorgridcolor <- "#D2E1E7"
textcolor <- "#5D544B"
backgroundcolor <- "#F98866"
backgroundcolor2 <- "white"
stripcolor <- "#D57457"


theme_stack <- function(){

theme_minimal(base_size = 12, base_family = NA) + 
theme(
  panel.grid.major = element_line(size = 0.9,
                                  color = majorgridcolor),
  panel.grid.minor = element_line(size = 0.5,
                                  color = minorgridcolor),
  panel.background = element_rect(color = textcolor, 
                                  fill = backgroundcolor2,
                                  size = 1.5),
  plot.background = element_rect(fill = backgroundcolor),
  axis.text = element_text(color = textcolor,
                           size = 13,
                           face = "bold"),
  legend.position = "bottom",
  legend.background = element_rect(fill = backgroundcolor,
                                   color = NA,
                                   size = 2),
  legend.key = element_rect(fill = backgroundcolor, 
                            color = NA),
  legend.text = element_text(color = textcolor,
                             face = "bold"),
  legend.title = element_text(color = textcolor,
                              face = "bold"),
  legend.key.size = unit(0.5, "cm"),
  axis.title = element_text(color = textcolor,
                            size = 14,
                            face = "bold"),
  plot.title = element_text(color = textcolor, 
                            hjust = 0.5,
                            size = 12),
  text = element_text(),
  plot.margin = unit(c(0.5,0.3,0.2,0.3), "cm"),
  axis.ticks=element_blank(),
  strip.background = element_rect(color = textcolor,
                                  fill = stripcolor,
                                  size = 1.5
                                  ),
  strip.text = element_text(color = textcolor,
                            face = "bold"),
  strip.placement = "inside",
  panel.ontop = FALSE
)
}

我是否忽略了主题设置?

0 个答案:

没有答案