It's not so much a problem, as not working the way you expected.
cluster:::plot.partition is used to do the plotting. If you look at the code for
this you can see the difficulty in putting every possible permutation into the
code. If for example you want the silhouette plot to be red using col =
"red" is not intuitive as the cluster plot (which comes up first) has
more than one colour. If you have a look at methods(plot) (assuming that you
have loaded the cluster package) you will see that there is a specific piece of
code in the form of plot.silhouette. It has an asterisk next to it so you need
to use cluster:::plot.silhouette to see the code. It has what you need.
args(cluster:::plot.silhouette)> function (x, nmax.lab = 40, max.strlen = 5, main = NULL, sub = NULL,
xlab = expression("Silhouette width " * s[i]), col =
"gray",
do.col.sort = length(col) > 1, border = 0, cex.names =
par("cex.axis"),
do.n.k = TRUE, do.clus.stat = TRUE, ...)
data(ruspini)
pr4 <- pam(ruspini, 4)
si <- silhouette(pr4)
plot(si,col = "red")
The issue is that whenever code is written there is always a choice as to what
functionality is put in place. Just because something can be done, does not mean
it will or in some cases should be done. In this case the help for
plot.partition notes that "For more flexibility, use
'plot(silhouette(x), ...)', see 'plot.silhouette'."
Tom
Thanks for that I found out something I will find useful in the future.
> -----Original Message-----
> From: r-help-bounces at stat.math.ethz.ch
> [mailto:r-help-bounces at stat.math.ethz.ch]On Behalf Of A. Mani
> Sent: Tuesday, 28 June 2005 4:30 AM
> To: r-help at stat.math.ethz.ch
> Subject: [R] A. Mani : colours in Silhouette
>
>
> Hello,
> In cluster analysis with cluster, how does one colour
> the silhouette
> plots ? For example in using pam. There seems to be some
> problem there.
> Everything else can be coloured.
>
> Thanks,
>
> A. Mani
> Member, Cal. Math. Soc
>
> ______________________________________________
> R-help at stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide!
> http://www.R-project.org/posting-guide.html
>