在geom_freqpoly行下填充区域的最简单方法是什么? [英] What is the simplest method to fill the area under a geom_freqpoly line?
问题描述
使用geom_histogram和geom_freqpoly绘制直方图或线条效果很好,但我希望有一个line,就像geom_freqpoly提供的那样,填充区域。
目前我使用的是geom_freqpoly,像这样:
ggplot(quake.data,aes(interval,fill = tweet.type))+ geom_freqpoly(aes(group = tweet.type,color = tweet.type))+ opts(axis .text.x = theme_text(angle = -60,hjust = 0,size = 6))
我宁愿有一个填充区域,例如由 geom_density
提供,但不会平滑该行: $ b
正如答案中所述,geom_area(.. 产生: 也许你想要: The x-axis is time broken up into time intervals. There is an interval column in the data frame that specifies the time for each row. The column is a factor, where each interval is a different factor level. Plotting a histogram or line using geom_histogram and geom_freqpoly works great, but I'd like to have a line, like that provided by geom_freqpoly, with the area filled. Currently I'm using geom_freqpoly like this: I would prefer to have a filled area, such as provided by The As stated in the answer, geom_area(..., stat = "bin") is the solution: produces: Perhaps you want:
这篇关于在geom_freqpoly行下填充区域的最简单方法是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
ggplot(quake.data,aes(interval))+ geom_area(()。,stat =bin)是解决方案: aes(y = ..count ..,fill = tweet.type,group = tweet.type),stat =bin)+ opts(axis.text.x = theme_text(angle = -60,hjust = 0,size = 6))
$ $ $ $ $ $ $ $ $ $ geom_area(aes(y = ..count ..),stat =bin)
ggplot(quake.data, aes(interval, fill=tweet.type)) + geom_freqpoly(aes(group = tweet.type, colour = tweet.type)) + opts(axis.text.x=theme_text(angle=-60, hjust=0, size = 6))
geom_density
, but without smoothing the line:geom_area
has been suggested, is there any way to use a ggplot2-generated statistic, such as ..count.., for the geom_area's y-values? Or, does the count aggregation need to occur prior to using ggplot2?
ggplot(quake.data, aes(interval)) + geom_area(aes(y = ..count.., fill = tweet.type, group = tweet.type), stat = "bin") + opts(axis.text.x=theme_text(angle=-60, hjust=0, size = 6))
geom_area(aes(y = ..count..), stat = "bin")