R版本与运行环境信息

  1. Date:2021-4-14
  2. R version 4.0.3 (2020-10-10)
  3. Platform: x86_64-w64-mingw32/x64 (64-bit)
  4. Running under: Windows 10 x64 (build 18363)

载入相关包

  1. library("tidyverse")

绘制热图

  1. setwd("")
  2. library("ggplot2")
  3. tem <- read.csv("Temperature.csv",header = T)
  4. names(tem) <- c("Sample_id","group","Tempreture")
  5. ggplot(tem,mapping = aes(group,Tempreture,color = group)) +
  6. geom_boxplot() + scale_fill_manual(values = c("red","gray","blue","pink"))
  7. ################
  8. #增加均值等信息fun:mean/median等均可
  9. #+ stat_summary(fun=mean, geom="point", shape=23, size=4)
  10. #增加抖动图,0.2为抖动程度,越大越稀疏
  11. #+ geom_jitter(shape=16, position=position_jitter(0.2))
  12. #+ geom_dotplot(binaxis = "y",stackdir = "center",position = "jitter",dotsize = 0.4)
  13. #横向图
  14. #+ coord_flip()
  15. #横轴的顺序&只有几组
  16. #+ scale_x_discrete(limits=c("T3","T2","CK","T1"))
  17. #+ scale_x_discrete(limits=c("T3","T2"))
  18. ###################
  19. #箱线图参数
  20. # geom_boxplot()
  21. #开口箱线图:geom_boxplot(notch=T)
  22. #单色填充
  23. #geom_boxplot(fill='#A4A4A4', color="black")
  24. #异常值的设置:
  25. #outlier.colour="red", outlier.shape=8, outlier.size=4
  26. #手工颜色设置(填充和边框色):
  27. #+ scale_fill_manual(values = c("red","gray","blue","pink"))
  28. #+ scale_color_manual(values = c("red","gray","blue","pink"))
  29. #添加误差线
  30. #+ stat_boxplot(geom = "errorbar" , width = 0.1)
  31. #修改箱子宽度
  32. # + geom_boxplot(width = 0.1)