[R] venn.diagram保存pdf格式文件?

vennDiagram包中的主函数绘图时,好像不直接支持PDF格式文件:

dat = list(a = group_out[[1]][,1],b = group_out[[2]][,1])
names(dat) <- group_names[1:2]

venn.plot <- venn.diagram(
  dat,
  filename = "proteinGroup_venn.tiff", #pdf error
  imagetype = "tiff",  #pdf error
  lwd = 3,
  col = "transparent",
  fill = c("cornflowerblue", "darkorchid1"),
  alpha = 0.6,
  label.col = "black",
  cex = 1.5,
  fontfamily = "serif",
  fontface = "bold",
  cat.col = c("cornflowerblue", "darkorchid1"),
  cat.cex = 2,
  cat.fontfamily = "serif",
  cat.fontface = "bold",
  margin = 0.05,
  cat.dist = c(0.03, 0.03),
  cat.pos = c(-20, 20)
)

直接使用pdf保存矢量图时不行,只能用tiff等其他矢量图格式。但在函数外结合grid.draw可以保存:

venn.plot <- venn.diagram(
  dat,
  filename = NULL, #设为空
  lwd = 3,
  col = "transparent",
  fill = c("cornflowerblue", "darkorchid1"),
  alpha = 0.6,
  label.col = "black",
  cex = 1.5,
  fontfamily = "serif",
  fontface = "bold",
  cat.col = c("cornflowerblue", "darkorchid1"),
  cat.cex = 2,
  cat.fontfamily = "serif",
  cat.fontface = "bold",
  margin = 0.05,
  cat.dist = c(0.03, 0.03),
  cat.pos = c(-20, 20)
)

pdf(file="proteinGroup_venn.pdf")
grid.draw(venn.plot)
dev.off()

如果不行,先安装加载library(grDevices)包。图如下:
image.png

Ref:https://stackoverflow.com/questions/14243609/problems-with-venndiagram

posted @ 2019-09-29 21:11  生物信息与育种  阅读(2555)  评论(0编辑  收藏  举报