1

在下面的示例数据框中,我想要 2 段 y 轴(在 y 轴上中断),以便更好地可视化“lna1”中的较小值。我已经尝试过 facet_wrap 但我想使用 facet_grid 比较具有相同 y 尺度的基因。

df<-data.frame(stimulation=rep(rep(c("a","b","c"), each=3),2),
           LNA=rep(c("lna1","lna2"),each=9), 
           foldchange=c(5,6,7,10,11,12,4,3,2,40,45,55,7,8,10,99,100,101))
n <- 3  
df<-do.call("rbind", replicate(n, df, simplify = FALSE))%>%
  mutate(genes=rep(c("gene1","gene2","gene3"), each=18))



ggplot(df, aes(x=LNA, y=foldchange,fill = stimulation))+
  geom_point() +
  geom_boxplot(alpha = 0.2) +
  theme(axis.text.x = element_text(angle = 60, hjust = 1)
        ,legend.background = element_rect(fill = "white", colour = NA)) +
  geom_hline(yintercept = 1) +
  scale_x_discrete(limits=c("lna1","lna2")) +
  facet_grid(stimulation~genes, scales="free")

阴谋

4

0 回答 0