What is the simplest method to fill the area under a geom_freqpoly line?

Posted by mattrepl on Stack Overflow See other posts from Stack Overflow or by mattrepl
Published on 2010-05-02T19:21:48Z Indexed on 2010/05/03 13:48 UTC
Read the original article Hit count: 255

Filed under:
|
|

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:

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))

alt text

I would prefer to have a filled area, such as provided by geom_density, but without smoothing the line: alt text

UPDATE:

The 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?

© Stack Overflow or respective owner

Related posts about rstats

Related posts about r