Dear R help members,
I have constructed a bar plot using ggplot, where I am showing the number of
particles in 10m depth bins (from 0-150m) by release area (3 different ones) and
Model (also 3 different ones). My problem is that for each release area a
different number of particles was released (say 35, 45 and 56). I now need to be
able to show the number of particles in each depth bin proportional to the
number of particles originally released. So that all bars that show release area
1 are divided by 35, those for release area 2 divided by 45 and those for
release area 3 by 56. Is it possible to do this in ggplot? I thought that it
would work using the following code, but I don't think its doing what I need
it to do:
AreaTidalEnd.df<-read.csv("./Analyses/Dispersal_Modelling/Data/AreaTidalEnd.csv",
header=TRUE)
AreaTidalEnd.df$Model<-factor(as.character(AreaTidalEnd.df$Model),levels=c("extP","extL","extT"))
levels(AreaTidalEnd.df$Model)[levels(AreaTidalEnd.df$Model)=="extP"]
<- "PTS"
levels(AreaTidalEnd.df$Model)[levels(AreaTidalEnd.df$Model)=="extL"]
<- "LGS"
levels(AreaTidalEnd.df$Model)[levels(AreaTidalEnd.df$Model)=="extT"]
<- "TDS"
AreaTidalEnd.df$Year<-as.factor(as.character(AreaTidalEnd.df$Year))
breaks<-seq(0,150,20)
AreaTidal.df<-subset(AreaTidalEnd.df, Depth>=0)
AreaTidal2003<-subset(AreaTidal.df, Year=="2003")
##Counts per Model and RA
update_stat_defaults("bin",aes(y=..density..))
qplot(Depth, data = AreaTidal2003, binwidth = 10, origin=0,xlim=c(0,150),
ylab="Larval Ratio")+ scale_x_continuous(breaks = breaks,
labels=breaks)+facet_grid(Release_Area~Model)
I would be hugely grateful for your help!
Melanie
____________________________________________
Melanie Z?lck (Zoelck)
PhD Candidate
Galway-Mayo Institute of Technology
Marine and Freshwater Research Centre
Commercial Fisheries Research Group
Department of Life Science
Dublin Road
Galway
Republic of Ireland
Mobile: +353 (0) 85 7246196
Skype: melaniezoelck
E-mail: mzoelck at gmx.com or mzoelck at hotmaill.com