| plot.mbcfit | R Documentation |
This function provides a plot method for objects of class mbcfit,
returned as output by the gmix function. It serves as a
wrapper around plot_clustering, allowing easy visualization
of clustering results, including clustering assignments, contours, and
boundaries.
## S3 method for class 'mbcfit'
plot(
x,
data = NULL,
subset = NULL,
what = c("clustering", "contour"),
col_cl = NULL,
pch_cl = NULL,
...
)
x |
An object of class |
data |
|
subset |
A numeric vector indexing columns of |
what |
Character vector specifying which elements to plot. Options are
|
col_cl |
A vector of colors to use for clusters (one for each cluster).
Default is |
pch_cl |
A vector of plotting symbols (one for each cluster) to use for
clusters. Default is |
... |
Further arguments passed to or from other methods. |
The plot.mbcfit function provides a plotting method for objects of
class mbcfit. It acts as a wrapper around the
plot_clustering function, allowing users to easily generate
various plots to analyze the clustering results. A plot is produced only
upon a successful mbcfit estimate, i.e., when mbcfit has
code equal to either 1 or 2. The plot features that can
actually be drawn depend on the components stored in x, in
particular x$params and x$cluster.
When data is NULL (the default), the function constructs a
synthetic plotting data set from the fitted params and then delegates
the plotting to plot_clustering.
When data is not NULL, the function passes data, the
stored mixture parameters, and the hard clustering labels saved in
x$cluster to plot_clustering.
Called for its side effects.
gmix, plot_clustering,
predict.mbcfit
# load data
data("banknote")
dat <- banknote[-1]
# fit 2 clusters
set.seed(123)
fit <- gmix(dat, K = 2, init.nstart = 1)
print(fit)
# plot partition (default)
plot(x = fit, data = dat)
# plot partition onto the first 3 coordinates
plot(x = fit, data = dat, subset = c(1:3), pch_cl = c("A", "B"),
col_cl = c("#4285F4", "#0F9D58"), what = "clustering")
# additionally plot clustering boundary and contour sets
plot(x = fit, data = dat, subset = c(1:3), pch_cl = c("A", "B"),
col_cl = c("#4285F4", "#0F9D58"),
what = c("clustering", "boundary", "contour"))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.