Plot Histogram with Points Instead of Bars

故事扮演 提交于 2019-11-29 06:46:54
Solomon Choe

Greg Snow's TeachingDemos package contains a dots(x, ...) function which seems to fit your need:

dots( round( rnorm(50, 10,3) ) )

You can do this yourself pretty quickly:

x <- c(1,1,2,1,2,3,3,3,4,4)
plot(sort(x), sequence(table(x)))

The simplest answer I know is this:

x <- c(1,1,2,1,2,3,3,3,4,4)
stripchart(x,method="stack",at=0)

It's better than Jonathan Chang's suggestion because stripchart does proper stacking of points.

Another easy way would be:

x <- c(1,1,2,1,2,3,3,3,4,4)
myhist <- hist(x)
myhistX <- myhist$mids
myhistY <- myhist$density

And now you can plot it in any way you like:

plot(myhistY~myhistX)

This way you can change the stacking options when building a "histogram" object.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!