[R] Colours in silhouette plots (cluster package)
Patrick Connolly
p_connolly at ihug.co.nz
Thu Aug 10 11:00:52 CEST 2006
I tried using colours in silhouette plots by specifying a vector of
colours instead of the default "gray" for the col parameter.
No bars are drawn, though the rest of the plot works as it did with
the grey bars. On investigating cluster:::plot.silhouette, I came
across this part:
if (do.col.sort && (lc <- length(col)) > 1) {
if (lc == k)
col <- col[cli]
else if (lc != n)
col <- rep(col, length = n)
col <- rev(col[attr(x, "iOrd")])
}
Since attr(x, "iOrd") was NULL, I would end up with an empty col
vector which explained why I didn't get any bars.
When I removed [attr(x, "iOrd")], the plot worked how I think it's
meant to. The silhouette object I used was created from one obtained
from the pam function in the same package. I've not tried plotting
other types, so I can't say how general the phenomenon could be.
Could it be that the "iOrd" part belongs when some other conditions
apply or is it some left over code from a previous version? Or is it
just that I've done something silly?
platform x86_64-unknown-linux-gnu
arch x86_64
os linux-gnu
system x86_64, linux-gnu
status
major 2
minor 3.1
year 2006
month 06
day 01
svn rev 38247
language R
version.string Version 2.3.1 (2006-06-01)
Along with cluster with that distribution:
Packaged: Wed May 17 09:56:22 2006; maechler
Built: R 2.3.1; x86_64-unknown-linux-gnu; 2006-06-05 11:57:15;
unix
best
--
~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.
___ Patrick Connolly
{~._.~} Great minds discuss ideas
_( Y )_ Middle minds discuss events
(:_~*~_:) Small minds discuss people
(_)-(_) ..... Anon
~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.
More information about the R-help
mailing list