0

我已经为我的聚类分析创建了一个段剖面图,但我遇到了barchart()命令格式的问题。这是我创建的图表。明显的问题是我的台词靠得太近而无法阅读。明显的问题是我的线太靠近了

在这里你可以看到我用来创建这个图表的代码。有人可以告诉我要添加什么以使此图表可读吗?下面是我使用的代码示例。

用于重现我们使用的聚类和 PCA 的 R 代码:

## if not installed, install: install.packages("flexclust")
library("flexclust")
load("vacpref.RData")
cl6 <- kcca(vacpref, k=vacpref6, control=list(iter=0),
            simple=FALSE, save.data=TRUE)
summary(cl6)

变量的层次聚类

varhier <- hclust(dist(t(vacpref)), "ward")
par(mar=c(0,0,0,15))
plot(as.dendrogram(varhier), xlab="", horiz=TRUE,yaxt="n")

主成分投影

vacpca <- prcomp(vacpref)

用于生成段分离图的 R 代码

pairs(cl6, project=vacpca, which=1:3, asp=TRUE,points=FALSE, 
      hull.args=list(density=10))

用于生成段定位图的 R 代码:

col <- flxColors(1:6)
col[c(1,3)] <- flxColors(1:4, "light")[c(1,3)]
par(mar=rep(0,4))
plot(cl6, project=vacpca, which=2:3,
     col=col,asp=TRUE,points=F,hull.args=list(density=10),axes=FALSE)
projAxes(vacpca, minradius=.5, which=2:3, lwd=2, col=”darkblue”)

用于生成段剖面图的 R 代码:

barchart(cl6, shade=TRUE, which=rev(varhier$order),legend=TRUE)

最后一个命令是我用来创建分段剖面图的命令,但我不确定之前的命令是否会以任何方式影响它。我是 R 的新手。

4

1 回答 1

0

我经常使用的一个技巧是通过导出图像来更改宽度/高度和分辨率。尝试这个:

png("c:\\temp\\myCrazyPlot.png", res=250, height=8, width=12, unit="in")
  barchart(cl6, shade=TRUE, which=rev(varhier$order),legend=TRUE)
  # And whatever other plot commands for the same plot
dev.off()

然后去检查你的 .png 文件。通过修改高度和宽度,您可以以某种方式调整标签在 y 轴上的间距。你甚至可以让它的高度比它的宽度长,让标签散开。(我认为目前你不能这样做,因为这是你屏幕的最大高度?)

于 2013-09-26T23:29:20.867 回答