我使用VennDiagram使用以下示例代码制作维恩图:
library(VennDiagram)
venn.diagram(list(shams_90d = 1:3, shams_90d_4h = 2:4, sham3__shams_90d = 3:5,
sham3_90d__shams = 5:7, sham3_90d__shams_4h = 6:9),
fill = c("red", "green", "blue", "yellow", "purple"),
alpha = c(0.5, 0.5,0.5, 0.5, 0.5), cex = 1,cat.fontface = 2,
lty =1, filename = "trial2.emf");
这给出了这个数字:
图中左侧和右侧的名称被切掉,底部也有一点名称。我尝试改变宽度,但这使得维恩图本身变宽,名字仍然被切断。
如何通过在图表的左侧和右侧添加更多的空格,或者将名称更多地推向维恩图来制作VennDiagram,使其包含全名?
答案 0 :(得分:10)
您可以使用cat.just
证明标签文字的合理性。包参考手册提供了信息。关于如何传递参数。
对于您的示例,我使用了试验和错误来证明理由值。
# Plot
v <- venn.diagram(list(shams_90d = 1:3, shams_90d_4h = 2:4, sham3__shams_90d = 3:5,
sham3_90d__shams = 5:7, sham3_90d__shams_4h = 6:9),
fill = c("red", "green", "blue", "yellow", "purple"),
alpha = c(0.5, 0.5,0.5, 0.5, 0.5), cex = 1,cat.fontface = 2,
lty =1, filename=NULL, cat.cex=0.8,
cat.just=list(c(0.6,1) , c(0,0) , c(0,0) , c(1,1) , c(1,0)))
grid.newpage()
grid.draw(v)
另一个选项(如果有点快速破解)将删除cat.just
参数并设置较小的grid::viewport
。您可能需要调整图形窗口/输出设备的宽度(即pdf(..., width=...)
):
# Plot
v <- venn.diagram(list(shams_90d = 1:3, shams_90d_4h = 2:4, sham3__shams_90d = 3:5,
sham3_90d__shams = 5:7, sham3_90d__shams_4h = 6:9),
fill = c("red", "green", "blue", "yellow", "purple"),
alpha = c(0.5, 0.5,0.5, 0.5, 0.5), cex = 1,cat.fontface = 2,
lty =1, filename=NULL, cat.cex=0.8)
grid.newpage()
pushViewport(viewport(width=unit(0.8, "npc"), height = unit(0.8, "npc")))
grid.draw(v)