polygon_list_labelr | R Documentation |
Simple wrapper to polylabelr::poi() for polygon_list
polygon_list_labelr(polygon_list, precision = 1, add_labels = FALSE, ...)
polygon_list |
|
matrix
with nrow length(polygon_list)
with x,y coordinates
representing the visual center of each polygon in the list.
Other venndir polygons:
bbox_polygon_list()
,
eulerr_to_polygon_list()
,
get_largest_polygon_list()
,
get_venn_polygon_shapes()
,
intersect_polygon_list()
,
labelr_polygon_list()
,
minus_polygon_list()
,
nudge_polygon_coords()
,
nudge_polygon_list()
,
plot_polygon_list()
,
polygon_areas()
,
polygon_circles()
,
polygon_ellipses()
,
polygon_list_to_xy_list()
,
rescale_polygon_list()
,
simple_ellipse()
,
union_polygon_list()
,
xy_list_to_polygon_list()
counts <- c(A=1, B=2, `A&B`=3, C=5, `B&C`=2, `A&C`=2, `A&B&C`=1)
x <- eulerr::euler(counts)
polygon_list <- eulerr_to_polygon_list(x)
# default is to label each polygon in its center
plot_polygon_list(polygon_list,
col=colorjam::rainbowJam(length(polygon_list), alpha=0.5))
polygon_list_labelr(polygon_list, add_labels=TRUE)
# create unique polygons for each label
A_only <- minus_polygon_list(polygon_list, new_name="A_only");
B_only <- minus_polygon_list(polygon_list[c(2,1,3)], new_name="B_only");
C_only <- minus_polygon_list(polygon_list[c(3,1,2)], new_name="C_only");
plot_polygon_list(polygon_list,
col=colorjam::rainbowJam(length(polygon_list), alpha=0.5))
ABC_only <- c(A_only, B_only, C_only);
polygon_list_labelr(ABC_only, add_labels=TRUE)
# label ABC intersection
ABC_int <- intersect_polygon_list(polygon_list[c(1,2,3)], new_name="ABC");
plot_polygon_list(ABC_int, add=TRUE, col="gold")
polygon_list_labelr(ABC_int, add_labels=TRUE)
# label AB intersection
AB_only <- minus_polygon_list(
c(intersect_polygon_list(polygon_list[c(1,2)], new_name="BC_only"),
polygon_list[3]))
plot_polygon_list(AB_only, add=TRUE, col="darkviolet")
polygon_list_labelr(AB_only, add_labels=TRUE, col="white")
# label BC intersection
BC_only <- minus_polygon_list(
c(intersect_polygon_list(polygon_list[c(2,3)], new_name="BC_only"),
polygon_list[1]))
plot_polygon_list(BC_only, add=TRUE, col="skyblue")
polygon_list_labelr(BC_only, add_labels=TRUE)
# test with fully overlapping polygon (to create a hole)
counts <- c(A=5, B=0, C=3, `A&B`=1)
x <- eulerr::euler(counts)
polygon_list <- eulerr_to_polygon_list(x)
plot_polygon_list(polygon_list[1:3], col=c("red"))
A_only <- minus_polygon_list(polygon_list[c(1, 2, 3)], new_name="A_only");
plot_polygon_list(A_only, col="gold", add=TRUE)
polygon_list_labelr(A_only, add_labels=TRUE)
polygon_list_labelr(c(A_only, polygon_list[2:3]), add_labels=TRUE)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.