如何强制标签适合VennDiagram? [英] How to force the labels to fit in VennDiagram?

查看:100
本文介绍了如何强制标签适合VennDiagram?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用VennDiagram通过以下示例代码制作维恩图:

I use VennDiagram to make a venn diagram with the following example code:

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");

哪个给出了这个数字:

图中左右两边的名称都被切除,底部也有一点点名称.我尝试更改宽度,但这会使维恩图本身变宽,并且名称仍然被切断.

The names on the left and right of the figure are cut off, and a little bit of the name at the bottom as well. I tried changing width, but that makes the venn diagram itself get wider, and the names still get cut off.

如何通过在图的左侧和右侧添加更多空格或将名称更多推向venn图,使VennDiagram包含全名?

How can I make the VennDiagram so that it includes the full names, either by adding more whitespace on the left and right of the diagram, or by pushing the names more towards the venn diagram?

推荐答案

您可以使用cat.just来对齐标签文本.软件包参考手册提供了信息.有关如何传递参数的信息.

You can justify the label text with cat.just. The package reference manual gives info. on how to pass the parameters.

在您的示例中,我使用了反复试验作为理由值.

For your example i used trial and error for the justification values.

# 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=...)):

Another option (if a bit of a quick hack) would be to remove the cat.just argument and set a smaller grid::viewport. You may need to tweak the width of your graphics window / output device (ie 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)

这篇关于如何强制标签适合VennDiagram?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆