-3

这是一个情节,我如何在R中绘制它?

在此处输入图像描述

4

3 回答 3

22

基 R 函数是stripchart一个最小的例子A制定的例子:

set.seed(1); A <- sample(0:10, 100, replace = TRUE)
stripchart(A, method = "stack", offset = .5, at = .15, pch = 19, 
           main = "Dotplot of Random Values", xlab = "Random Values")

在此处输入图像描述

您还可以offset尝试增加堆叠点之间的差距,并pch更改点类型。

于 2013-03-06T10:39:02.017 回答
7
library(ggplot2)
ggplot(mtcars, aes(x = mpg)) + geom_dotplot()
于 2013-03-06T10:37:50.310 回答
-1

仅供参考,这里是 y 轴点图的示例:

downv<- data.frame(
y<- c(rep(3,14),6,6,9,9,9,9,9.5,9.5,10.5,10.5,10.5,10.5,rep(11,8)),
l2<- c(rep(8,4),rep(6,6),4,4,8,8,8,4,rep(6,6),8,8,4,4,rep(6,8)),
l<- c(rep(0,7,),rep(1,7),0,1,0,0,1,1,0,1,0,0,1,1,rep(0,4),rep(1,4))
)

ggplot(downv, aes(x = factor(l), y = y, fill = factor(l2))) +
  geom_dotplot(binaxis = "y", stackdir = "center", position = "dodge", dotsize=3,  stackratio = .7) + 
scale_fill_manual(values=c("black", "black", "black"))


#need square aspect ratio    
于 2013-03-06T17:15:58.247 回答