R:增加ggplot2中分界线的大小

时间:2018-05-04 12:29:23

标签: r ggplot2

在这个情节中,我要处理以下问题:

enter image description here

我想增加正方形之间白色分界线的大小。情节代码是:

p <- ggplot(long_form_mittelwerte2, aes(Var1, Var2)) + 
  geom_tile(aes(fill = Rang), colour = "white") 

pneu2 <- p + 
  scale_fill_gradient(low = "white", high = "blue", limits= c(1, 3), breaks = c(1, 2, 3)) +
  geom_text(aes(label = mittelwerte_text2$value), size = 12, color = "gray0") +
  theme(axis.title.x = element_blank(),
        axis.title.y = element_blank()) +
  theme(axis.text.y = element_text(size = 30, color = "black"), 
        axis.text.x = element_text(size = 30, color = "black")) +
  scale_y_discrete(labels = c(h_Filter3x3="3x3", h_Filter3x5="3x5", h_Filter3x9="3x9"), 
                   expand = c(0, 0)) +
  scale_x_discrete(expand = c(0, 0)) +
  coord_fixed(ratio = 1) +
  guides(fill= guide_colorbar(barheight = unit(10, "cm"))) +
  theme(legend.text = element_text(size = 30, face = "bold"), 
        legend.title = element_blank())

如果您需要数据,请告诉我们。谢谢你的帮助。

1 个答案:

答案 0 :(得分:2)

您可以在size内设置colourgeom_tile参数,以调整图块之间的空间和颜色:

mtcars %>%
    ggplot(aes(cyl, am, fill = mpg)) + 
    geom_tile(colour = "white", size = 4)

enter image description here