Emp*_*cer 12 r histogram ggplot2
我想geom_histogram
为直方图提供垃圾箱的数量,而不是通过控制垃圾箱binwidth
.文档说我可以通过设置bins
参数来做到这一点.但是当我跑步的时候
ggplot(data = iris, aes(x = Sepal.Length)) + stat_bin(bins = 5)
Run Code Online (Sandbox Code Playgroud)
我得到一个带有30个bin的输出消息,好像我根本没有指定binwidth.
stat_bin:binwidth默认为范围/ 30.使用'binwidth = x'来调整它.
我已经试过这种说法喂养stat_bin
和qplot
同样的问题.难道我做错了什么?
我正在使用ggplot2版本1.0.1.
arv*_*000 22
bins=x
直接通过
library(ggplot2)
df <- data.frame(a = rnorm(10000))
ggplot(df, aes(x=a)) + geom_histogram()
Run Code Online (Sandbox Code Playgroud)
产生这个(警告" stat_bin()
使用bins = 30
.选择更好的价值binwidth
."):
还有这个:
ggplot(df, aes(x=a)) + geom_histogram(bins=10)
Run Code Online (Sandbox Code Playgroud)
生产:
使用ggplot2版本2.0.0