Using the following code to have a little separation between the individual bins:

VADeaths_flat_df = stack(as.data.frame(VADeaths))
names(VADeaths_flat_df) = c('Data','Person')
ggplot(VADeaths_flat_df, aes(Data, fill = Person)) + geom_bar(position=position_dodge(width =(15)), binwidth=20)

The result shows the bars overlapping.  

Is there any way to fix it by reducing the bar sizes? 

Thanks again. 

--- On Mon, 2/2/09, hadley wickham <h.wickham@gmail.com> wrote:
From: hadley wickham <h.wickham@gmail.com>
Subject: Re: [R] Broke ggplot...
To: jasonkrupert@yahoo.com
Cc: R-help@r-project.org
Date: Monday, February 2, 2009, 5:49 PM

On Mon, Feb 2, 2009 at 5:41 PM, Jason Rupert <jasonkrupert@yahoo.com>
wrote:
> It appears I broke ggplot in my script, but that maybe it is because the
caffeine has worn off or maybe it is late in the day.   I thought I was
beginning to understand ggplot, but I have encountered a silly little issue.
>
> For some reason the following does not produce a histogram with fill due
to the Person's characteristics:
> (Note that VADeaths_flat_df$Data works fine...)
>
>
> VADeaths_df<-data.frame(VADeaths)
...

You can do this a bit more easily with:

VADeaths_flat_df <- melt(VADeaths)
names(VADeaths_flat_df) <- c("Age", "Person",
"Data")

> bin_size<-15.0
> ggplot(VADeaths_flat_df, aes(x = factor(Data), fill = factor(Person))) +
geom_bar(position=position_dodge(width =(20)), binwidth=20)
> # or
> ggplot(VADeaths_flat_df, aes(x=factor(Data))) +
geom_histogram(binwidth=20)

Those plots look fine to me (well they're what I'd expect from the
definition), but I'd think you'd want

ggplot(VADeaths_flat_df, aes(Data, fill = Person)) +
  geom_histogram(binwidth=20)

or maybe

ggplot(VADeaths_flat_df, aes(Person, weight = Data)) + geom_bar()
ggplot(VADeaths_flat_df, aes(Person, weight = Data, fill = Age)) + geom_bar()

Hadley

-- 
http://had.co.nz/



      
	[[alternative HTML version deleted]]


