ggplot画组合热图,设置面板间距

发布时间 2023-11-15 18:42:45作者: 光华sv

ggplot(Data, aes(x = Cancer, y =Type, fill = Number)) +
geom_tile() +
scale_x_discrete(position="top") +    #设置x轴坐标位置

scale_fill_gradient(low = "white", high = "#0000ff") +  #设置热图颜色的过渡值
theme_minimal() +
facet_grid(Type ~ ., scales = "free_y", space = "free") +   #设置面板
theme(strip.placement = "outside", strip.background = element_blank(),
axis.title.y = element_blank(),          #删掉y轴的题目
axis.text.x = element_text(angle = 45, vjust = 1),    #设置x轴的坐标倾斜度
panel.spacing.y = unit(0.5, "mm"))    #设置每个面板的距离    panel.spacing.y = unit(0.5, "mm")、panel.spacing.x = unit(1, "cm")

 

参考:

ggplot2的一系列分面设置(全网最全) - 知乎 (zhihu.com)