Hallo Sebastian, >>>>> "SP" == Sebastian Pölsterl <s...@k-d-w.org> >>>>> on Sun, 14 Jun 2009 14:04:52 +0200 writes:
SP> Hello Martin, SP> I plotting the silhouette of a clustering and storing it as png. When I SP> try to store the image as png the bars are missing. The bars are plotted SP> when I use x11 or postscript as device. In addition, it seems to work SP> when I use a smaller matrix (e.g. ruspini). SP> Would be great if you have look at this issue. Hmm, I've been at a conference in Italy... The silhouette plot only uses standard R plotting functions, so any problem with it exposes problems in standard R graphics. --> Such a message should really go to R-help. to which I CC now. ---------- library(cluster) nmat <- matrix(rnorm(2500*300), ncol=300, nrow=2500) rmat <- matrix(rchisq(1000, 300, 50), ncol=300, nrow=1000) mat <- rbind(nmat, rmat) pr <- pam(mat, 2) sil <- silhouette(pr) png("sil.png") #postscript("sil.ps") plot(sil) dev.off() ---------- Anyway, I can confirm the "problem", but of course, it has not much to do with the silhouette function, but rather with the png() device which produces a bitmap, and the lines you draw are too fine (in the bitmap resolution) and so are "rounded to invisible". You can reproduce the problem much more simply: set.seed(1); x <- rlnorm(5000) png("bar.png");barplot(x,col="gray",border=0,horiz=TRUE);dev.off() system("eog bar.png &") ## which is also empty, and the completely analogue, replacing ## png [bitmap] with pdf [vector graphic] pdf("bar.pdf");barplot(x,col="gray",border=0,horiz=TRUE);dev.off() system("evince bar.pdf &") ## gives a very nice plot, into which you can zoom and see all details. ---------------- Now in principle you should be able to use png() with a much higher resolution than the default one, but replacing the above png("bar.bng") with png("bar.bng", res = 1200) did not help, as we now get the infamous Error in plot.new() : figure margins too large Other R-help readers will be able to make the png() example work for such cases, where you need so many lines. {but let's stick with barplot(*, border=0, *)} Regards, Martin Maechler, ETH Zurich ______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.