> setwd("") > library(openxlsx) > library(ggvenn) > data <- read.xlsx("韦恩图种2.xlsx") data$P <- ifelse(data$P == 0, "F", "T") data$N <- ifelse(data$N == 0, "F", "T") |
> data <- as.data.frame(data) > data <- as.data.frame(data) > sapply(data, class) species P N "character" "logical" "logical" > data$P<- as.logical(data$P) > data$N<- as.logical(data$N)
> head(data) species P N 1 [Candida] glabrata TRUE FALSE 2 [Clostridium] innocuum TRUE TRUE 3 [Haemophilus] ducreyi TRUE TRUE 4 [Ruminococcus] gnavus TRUE TRUE 5 Abiotrophia defectiva TRUE TRUE 6 Acholeplasma laidlawii TRUE FALSE
> p1 <- ggvenn(data, c("P", "N")) > p1
> p1 <- p1 + ggtitle("Species") + + theme(plot.title.position = "plot") + + theme(plot.title = element_text(hjust = 0.5)) > p1
> p1 <- p1 + theme( + text = element_text(size = 16) # 设置字体大小为 16 + ) > p1
#保存
ggsave("韦恩图.png", plot = p1, width = 10, height = 8, dpi = 150)
分辨率高了很多,这只是最基本的用法,想要画一个好图,得需要多次修改。