是否可以在同一张图中相邻绘制箱线图和条形图?如果我运行这段代码,条形图将覆盖箱线图。我真正想要的是他们并排躺着。以这种方式,将形成在x-as上具有10列的图形。这有可能吗?
boxplot(doubles[1:5,])
stripchart(doubles[6:10,],add=TRUE,vertical=TRUE, pch=19)

发布于 2011-12-06 00:21:45
数据的一些例子会很好,但最简单的选择可能是:
#random data corresponding to your 5 columns
x <- data.frame(V = rnorm(100), W = rnorm(100), X = rnorm(100), Y = rnorm(100),
Z = rnorm(100))
#remove axis with 'axes=F', define wider x-limits with 'xlim'
stripchart(x[1:5,],vertical=TRUE, pch=19,xlim=c(1,6),axes=F)
#add boxplots next to stripchart, decrease width with 'boxwex'
boxplot(x[1:5,],add=T,at=1.5:5.5,boxwex=0.25,axes=F)
#add custom x axis
axis(1,at=1.25:5.25,labels=names(x))

发布于 2011-12-06 02:33:00
使用ggplot2
library(ggplot2)
qplot(treatment, decrease, data = OrchardSprays) +
scale_y_log10() +
geom_boxplot() +
geom_point(colour = 'blue', alpha = 0.5)

https://stackoverflow.com/questions/8387088
复制相似问题