stat_chull | R Documentation |
Draws a (convex) polygon around the outermost points of a set of points. Useful as a visual aid for identifying groups of points on a scatterplot, such as an ordination plot.
stat_chull(
mapping = NULL,
data = NULL,
geom = "polygonHollow",
position = "identity",
na.rm = FALSE,
show.legend = NA,
inherit.aes = TRUE,
...
)
mapping |
Set of aesthetic mappings created by |
data |
The data to be displayed in this layer. There are three options: If A A |
geom |
The geometric object to use to display the data for this layer.
When using a
|
position |
A position adjustment to use on the data for this layer. This
can be used in various ways, including to prevent overplotting and
improving the display. The
|
na.rm |
If |
show.legend |
logical. Should this layer be included in the legends?
|
inherit.aes |
If |
... |
Other arguments passed on to
|
This is a ggplot2 extension - slightly modified from the original code found here:
https://CRAN.r-project.org/package=ggplot2/vignettes/extending-ggplot2.html
ggplot2::stat_ellipse
ord_plot
library(ggplot2)
microViz::ibd %>%
tax_fix() %>%
tax_transform(rank = "Genus", trans = "clr") %>%
ord_calc(method = "PCA") %>%
ord_plot(colour = "DiseaseState", shape = "DiseaseState", alpha = 0.5) +
stat_chull(aes(colour = DiseaseState))
microViz::ibd %>%
tax_fix() %>%
tax_transform(rank = "Genus", trans = "clr") %>%
ord_calc(method = "PCA") %>%
ord_plot(colour = "DiseaseState", shape = "DiseaseState", alpha = 0.5) +
stat_chull(aes(colour = DiseaseState, fill = DiseaseState), alpha = 0.1)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.