This is a case where it's easier to create the plot with ggplot, not qplot:
ggplot(mapping = aes(fill = "Pre-BBXL")) +
geom_histogram(aes(x), data = x, binwidth=0.25, colour="black") +
geom_histogram(aes(y), data = y, binwidth=0.25, colour="black") +
labs(x="ODs",y="count") +
xlim(0,14) +
scale_fill_brewer("Set1")
Hadley
> --
> You received this message because you are subscribed to the ggplot2 mailing list.
> Please provide a reproducible example: http://gist.github.com/270442
>
> To post: email ggp...@googlegroups.com
> To unsubscribe: email ggplot2+u...@googlegroups.com
> More options: http://groups.google.com/group/ggplot2
>
--
Assistant Professor / Dobelman Family Junior Chair
Department of Statistics / Rice University
http://had.co.nz/
##########
library(ggplot2)
x <- read.table(file="http://dl.dropbox.com/u/3734701/x.csv", sep=",",
header=TRUE)
y <- read.table(file="http://dl.dropbox.com/u/3734701/y.csv", sep=",",
header=TRUE)
dat <- data.frame(x=c(x$x, rep(NA, (nrow(y)-nrow(x)))), y=y$x)
ggplot(data=dat, mapping = aes(fill = "Pre-BBXL")) +
geom_histogram(aes(x=x), binwidth=0.25, colour="black") +
geom_histogram(aes(x=y, y=-..count..), binwidth=0.25, colour="black") +
labs(x="ODs",y="count") +
xlim(0,14) +
scale_fill_brewer("Set1")
############
--
Joshua Wiley
Ph.D. Student, Health Psychology
University of California, Los Angeles
http://www.joshuawiley.com/
Colouring the different histograms is not an issue with that format of
data, but I am not sure how to specify ..count.. and -..count..
without setting almost everything manually. Have you considered
faceting at all? I think it easier than trying to read an upside down
histogram. Here's an example:
##################
dat <- read.table(file="http://dl.dropbox.com/u/3734701/data.csv",
header=TRUE, sep=",", stringsAsFactors=FALSE)
dat[ , "category"] <- factor(dat[ , "category"],
levels=c("Pre-BBXL","Post-BBXL"), labels=c("Pre-BBXL","Post-BBXL"))
str(dat)
names(dat)
#########
library(ggplot2)
ggplot(data=dat, aes(x=totalODdna, group=category, fill=category)) +
geom_histogram(binwidth = 0.25, colour = "black") +
facet_wrap(~category) +
xlim(0, 14) +
scale_fill_brewer("Set1")
##################
>
> On Jun 30, 6:29 pm, Joshua Wiley <jwiley.ps...@gmail.com> wrote:
<snip>