# # reproducible example
library(ggVennDiagram)
set.seed(0)
small_list <- lapply(sample(0:10, size = 4), function(x){
sample(letters,x)
})
names(small_list) <- c("Mercury", "Venus", "Earth", "Mars")
# via ggVennDiagram
# how to remove "0 (0%)" from intersections without an element?
ggVennDiagram(small_list, label_alpha = 0)
ggVennDiagram(small_list,
category.names = LETTERS[1:4],
show_intersect = TRUE)
# via ggplot
# how to remove the "c(", ")", and quotation marks from each item label?
# how to remove "character(0)" from intersections without an element?
venn <- Venn(small_list)
data <- process_data(venn)
View(data)
ggplot() +
# 1. region count layer
geom_sf(aes(fill = count), data = venn_region(data)) +
# 2. set edge layer
geom_sf(aes(color = id), data = venn_setedge(data), show.legend = FALSE) +
# 3. set label layer
geom_sf_text(aes(label = name), data = venn_setlabel(data)) +
# 4. region label layer
# geom_sf_label(aes(label = count), data = venn_region(data)) +
geom_sf_label(aes(label = item), data=venn_region(data)) +
theme_void()
字符串
1条答案
按热度按时间edqdpe6u1#
虽然我可能不完全理解你想要绘制什么样的标签,但我希望这个想法可能会有所帮助:在标签函数中使用数据参数处理:
字符串
所以
character(0)
值和c(“",“”)被删除了。我注意到了一个事实,即项目没有为所有区域分配值: