labelr_polygon_list | R Documentation |
Calculate polygon label positions using Pole of Inaccessibility, otherwise known as the Visual Center.
labelr_polygon_list(polygon_list, add_labels = FALSE, ...)
polygon_list |
|
add_labels |
|
... |
additional arguments are passed to |
This function is a wrapper for polylabelr::poi()
except that it
is applied to a list
of polygons individually.
When any one polygon is composed of two smaller polygon components,
as encoded with a nested list of coordinates,
first the polygons are combined using union_polygon_list()
.
If the result is a single polygon, that is used to define the
label position. If the result is multiple separate polygon
components, the largest polygon component is used to find the label.
Other venndir polygons:
bbox_polygon_list()
,
eulerr_to_polygon_list()
,
get_largest_polygon_list()
,
get_venn_polygon_shapes()
,
intersect_polygon_list()
,
minus_polygon_list()
,
nudge_polygon_coords()
,
nudge_polygon_list()
,
plot_polygon_list()
,
polygon_areas()
,
polygon_circles()
,
polygon_ellipses()
,
polygon_list_labelr()
,
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))
labelr_polygon_list(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)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.