barplot-methods {flexclust} | R Documentation |
Barplot of cluster centers or other cluster statistics.
## S4 method for signature 'kcca': barplot(height, bycluster = TRUE, oneplot = TRUE, data = NULL, FUN=colMeans, main = deparse(substitute(height)), which = 1:height@k, names.arg = NULL, oma=par("oma"), col=NULL, mcol="darkred", srt=45, ...) ## S4 method for signature 'kcca': barchart(x, data, xlab="", strip.labels=NULL, strip.prefix="Cluster ", col=NULL, mcol="darkred", which=NULL, legend=FALSE, ...)
height, x |
An object of class "kcca" . |
bycluster |
If TRUE , then each barplot shows one
cluster. If FALSE , then each barplot compares all cluster for
one input variable. |
oneplot |
If TRUE , all barplots are plotted together on
one page, else each plot is on a separate page. |
data |
If not NULL , cluster membership is predicted for
the new data and used for the plots. By default the
values from the training data are used. Ignored by the barchart
method. |
FUN |
The function to be applied to each cluster for calculating
the bar heights. Only used, if data is not NULL . |
which |
For barplot index number of clusters for the plot,
for barchart index numbers or names of variables to plot. |
names.arg |
A vector of names to be plotted below each bar. |
main, oma, xlab, ... |
Graphical parameters. |
col |
Vector of colors for the clusters. |
mcol |
If not NULL , the value of
FUN for the complete data set is plotted over each bar as a
line segment with color mcol . |
srt |
Number between 0 and 90, rotation of the x-axis labels. |
strip.labels |
Vector of strings for the strips of the Trellis display. |
strip.prefix |
Prefix string for the strips of the Trellis display. |
legend |
If TRUE , the barchart is always plotted on the
current graphics device and a legend is added to the bottom of the
plot. |
The flexclust barchart method uses a horizontal arrangements of the bars, and sorts them from top to bottom. Default barcharts in lattice are the other way round (bottom to top). See the examples below how this affects, e.g., manual labels for the y axis.
Friedrich Leisch
cl <- cclust(iris[,-5], k=3) barplot(cl) barplot(cl, bycluster=FALSE) ## plot the maximum instead of mean value per cluster: barplot(cl, bycluster=FALSE, data=iris[,-5], FUN=function(x) apply(x,2,max)) ## use lattice for plotting: barchart(cl) ## automatic abbreviation of labels barchart(cl, scales=list(abbreviate=TRUE)) ## Use manual labels. Note that the flexclust barchart orders bars ## from top to bottom (the default does it the other way round), hence ## we have to rev() the labels: LAB <- c("SL", "SW", "PL", "PW") barchart(cl, scales=list(y=list(labels=rev(LAB))))