Learn R Programming

tidylearn (version 0.1.0)

plot_clusters: Plot Clusters in 2D Space

Description

Visualize clustering results using first two dimensions or specified dimensions

Usage

plot_clusters(
  data,
  cluster_col = "cluster",
  x_col = NULL,
  y_col = NULL,
  centers = NULL,
  title = "Cluster Plot",
  color_noise_black = TRUE
)

Value

A ggplot object

Arguments

data

A data frame with cluster assignments

cluster_col

Name of cluster column (default: "cluster")

x_col

X-axis variable (if NULL, uses first numeric column)

y_col

Y-axis variable (if NULL, uses second numeric column)

centers

Optional data frame of cluster centers

title

Plot title

color_noise_black

If TRUE, color noise points (cluster 0) black