如何改变ggplot中的binwidth?
我正在用 ggplot 做直方图。
p <- ggplot(TotCalc, aes(x=x,y=100*(..count../sum(..count..)))) +
xlab(xlabel) + ylab(ylabel) +
geom_histogram(colour = "darkblue", fill = "white", binwidth=500)
我的 x 介于 2 到 6580 之间,我有 2600 个数据。
我想绘制一个具有不同 binwidth
的直方图。是否可以?
例如,我想要 8 个条形,宽度如下:
c(180,100,110,160,200,250,1000,3000)
我该怎么做?
I'am doing histogram with ggplot.
p <- ggplot(TotCalc, aes(x=x,y=100*(..count../sum(..count..)))) +
xlab(xlabel) + ylab(ylabel) +
geom_histogram(colour = "darkblue", fill = "white", binwidth=500)
my x is between 2 and 6580 and I have 2600 data.
I want to plot one histogram with different binwidth
. Is it possible?
For example, I want to have 8 bars, with width like this:
c(180,100,110,160,200,250,1000,3000)
How can I do it?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
使用休息时间怎么样?
PS 未经明确通知,请勿转载。
how about using breaks?
P.S. Please don't cross post without explicit notification.
使用
breaks
和position="dodge"
例如:
没有您的数据,但对于您的示例:
Use
breaks
andposition="dodge"
eg:
Don't have your data, but for your example: