qplot(carat,data=diamonds,geom="histogram",binwidth=1,xlim=c(0,3))
我用这段代码绘制直方图。但结果与书本不同。
发布于 2017-05-28 22:36:28
有两种可能性,要么使用center
参数作为suggested by Richard Telford,要么使用boundary
参数。
下面这两个代码将创建相同的图表:
library(ggplot2) # CRAN version 2.2.1 used
qplot(carat, data=diamonds, geom = "histogram", binwidth = 1, xlim = c(0,3),
center = 0.5)
qplot(carat, data=diamonds, geom = "histogram", binwidth = 1, xlim = c(0,3),
boundary = 0)
有关更多细节,请参见?geom_histogram
。
https://stackoverflow.com/questions/44229652
复制