英文:
How to turn on the scaling in a triple Venn diagram?
问题
grid.newpage() # 移动到新的绘图页面
draw.triple.venn(area1 = 153, # 每个集合使用不同的颜色
area2 = 173,
area3 = 224,
n12 = 2,
n23 = 26,
n13 = 8,
n123 = 140,
col = "red",
fill = c("pink", "green", "orange"), scaled = TRUE)
英文:
I am trying to build the following diagram but while it must be possible (see the picture), I have an error about the negative area.
I also need my diagram scaled.
grid.newpage() # Move to new plotting page
draw.triple.venn(area1 = 153, # Different color for each set
area2 = 173,
area3 = 224,
n12 = 2,
n23 = 26,
n13 = 8,
n123 = 140,
col = "red",
fill = c("pink", "green", "orange"), scaled = TRUE)
答案1
得分: 2
library(VennDiagram)
grid.newpage() # 移至新的绘图页面
draw.triple.venn(area1 = 153, # 每个集合的面积
area2 = 173,
area3 = 224,
n12 = 142,
n23 = 166,
n13 = 148,
n123 = 140,
col = "red",
fill = c("pink", "green", "orange"), scaled = TRUE)
创建于2023年3月20日,使用 reprex v2.0.2
<details>
<summary>英文:</summary>
You have to make sure your areas are correctly summed in the arguments like this:
``` r
library(VennDiagram)
grid.newpage() # Move to new plotting page
draw.triple.venn(area1 = 153, # Different color for each set
area2 = 173,
area3 = 224,
n12 = 142,
n23 = 166,
n13 = 148,
n123 = 140,
col = "red",
fill = c("pink", "green", "orange"), scaled = TRUE)
<!-- -->
#> (polygon[GRID.polygon.1], polygon[GRID.polygon.2], polygon[GRID.polygon.3], polygon[GRID.polygon.4], polygon[GRID.polygon.5], polygon[GRID.polygon.6], text[GRID.text.7], text[GRID.text.8], text[GRID.text.9], text[GRID.text.10], text[GRID.text.11], text[GRID.text.12], text[GRID.text.13], text[GRID.text.14], text[GRID.text.15], text[GRID.text.16])
<sup>Created on 2023-03-20 with reprex v2.0.2</sup>
答案2
得分: 2
如果您希望图表按比例缩放,使每个区域的大小大致与其包含的数量成比例,您应该使用 eulerr
包。请注意,在您的示例中,三个区域之间的重叠部分非常大,以至于几乎无法再识别为维恩图表了。以下是示例代码:
library(eulerr)
plot(euler(c(
"a" = 3, "b" = 5, "c" = 50,
"a&b" = 2, "a&c" = 8, "b&c" = 26,
"a&b&c" = 140
)), quantities = TRUE,
fills = scales::alpha(c("pink", "green", "orange"), 0.3))
英文:
If you want the diagram to be scaled so that all the areas are (approximately) proportional to the number each contains, you should use the eulerr
package instead. Note that in your example, the overlap between the three areas is so large that it is barely recognizable as a Venn Diagram any more:
library(eulerr)
plot(euler(c(
"a" = 3, "b" = 5, "c" = 50,
"a&b" = 2, "a&c" = 8, "b&c" = 26,
"a&b&c" = 140
)), quantities = TRUE,
fills = scales::alpha(c("pink", "green", "orange"), 0.3))
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论