Sorted silhouette widths grouped by cluster, with the mean marked — the standard visual check on how well-separated a clustering is.

geom_silhouette(mapping = NULL, data = NULL, alpha = NULL)

Arguments

mapping, data

Standard layer overrides. Map the silhouette width to x and the cluster to y (or color).

alpha

Bar opacity.

Value

A Layer to add with +.

Examples

set.seed(1)
d <- data.frame(
  cluster = rep(c("1", "2", "3"), each = 20),
  width = c(runif(20, .3, .9), runif(20, .1, .7), runif(20, -.1, .6))
)
ggnext(d, aes(width, cluster, color = cluster)) + geom_silhouette()
#> <ggnext plot>
#>   data:  60 x 2
#>   aes:   x = width, y = cluster, color = cluster
#>   layers: 1 
#>   coord: cartesian
#>   mode:  static