Skip to content
Prev 169000 / 398506 Next

overlapping bars on "dodge" ggplot histogram - can it be fixed?

Hi Jason,

I can't see anyway to do this completely within in ggplot.  And it's
not easy to do the data processing yourself.  Here's one attempt that
almost works:

counts <- ddply(VADeaths_flat_df, .(round_any(Data, 20), Person), nrow)
names(counts) <- c("bin", "person", "n")

qplot(bin, n, data = counts, fill = person, geom="bar", stat
="identity", position="dodge")

Or maybe:

counts <- ddply(VADeaths_flat_df, .(cut(Data,
breaks=fullseq(range(Data), 20)), Person), nrow)
names(counts) <- c("bin", "person", "n")

qplot(person, n, data = counts, fill = person, geom="bar", stat
="identity", width = 0.9) +
  facet_grid(. ~ bin) +
  opts(axis.text.x = theme_text(angle = 45, hjust = 1, colour = "grey60"))

Hadley
On Mon, Feb 2, 2009 at 8:32 PM, Jason Rupert <jasonkrupert at yahoo.com> wrote: