2012-03-26 58 views
1

我使用下面的代碼以產生多個箱圖,由變量的平均值排名:添加指向水平箱圖

zx <- replicate (5, rnorm(50)) 
zx_means <- (colMeans(zx, na.rm = TRUE)) 
colnames (zx) <- seq_len (ncol (zx)) 
boxplot(zx [, order (zx_means)], horizontal = FALSE, outline = FALSE) 
points(zx_means [ order (zx_means)], pch = 22, col = "darkgrey", lwd = 7) 

See this post for more details

當我更改代碼以horizontal = TRUE,我無法將這些積分與箱形圖相匹配。任何想法如何正確添加points水平箱圖?

回答

2

你需要給x和y座標:

points(zx_means[order (zx_means)], seq_along(zx_means), 
     pch = 22, col = "darkgrey", lwd = 7) 

points(zx_means, order (zx_means), pch = 22, col = "darkgrey", lwd = 7)