绝世美图

【傻瓜美图】桑葚能量流动图

2023-04-21  本文已影响0人  pudding815

数据格式整理为


数据格式

图的意思是做了差异基因从0-4-12小时的变化分类

library(ggalluvial)
##-----------示例数据及代码——————————————————————————
titanic_wide <- data.frame(Titanic)
head(titanic_wide)
ggplot(data = titanic_wide,
       aes(axis1 = Class, axis2 = Sex, axis3 = Age,
           y = Freq)) +
  scale_x_discrete(limits = c("Class", "Sex", "Age"), expand = c(.2, .05)) +
  xlab("Demographic") +
  geom_alluvium(aes(fill = Survived)) +
  geom_stratum() +
  geom_text(stat = "stratum", aes(label = after_stat(stratum))) +
  theme_minimal() +
  ggtitle("passengers on the maiden voyage of the Titanic",
          "stratified by demographics and survival")

-------------自己数据照搬试试一下下

data <- read.csv("test.csv",header = T)
ggplot(data,
       aes(y = Freq, axis1 = cluster, axis2 = H4_vs_H0change, axis3 =H12_vs_H4change)) +
  geom_alluvium(aes(fill =color )) +
  geom_stratum(width = .3) +
  scale_x_discrete(limits = c("cluster", "H4_vs_H0change", "H12_vs_H4change"), 
                   expand = c(.05, .05)) +
  theme_void()+
  geom_text(stat = "stratum", aes(label = after_stat(stratum)),size=5)+
  #scale_fill_manual(values = pal_npg()(7))
  #geom_flow(width =0.3,curve_type = "sine",color = 'white',size = 0.1)+
  #scale_fill_brewer(type = "qual", palette = "palette1")
  scale_fill_manual(values = c("navy", "grey","firebrick3","#70493D","#E2AC76",
"#3F752B","#81B0E4"))
  #scale_fill_manual(values = col)
  #xlab("Demographic")+
  #ggtitle("passengers on the maiden voyage of the Titanic",
          "stratified by demographics and survival")
image.png
上一篇 下一篇

猜你喜欢

热点阅读