Hi Ellen,
> library(ggplot2)
> plot<-ggplot(dataset, aes(x=area,
> y=var,group=station))+geom_bar(width=0.5,colour="black",fill="white",stat="identity",position=position_dodge(width=0.6),drop=F)+scale_y_continuous("Sediment
> depth averaged TOM (%)\n",limits=c(0,8),expand=c(0,0))+scale_x_discrete("")
> plot
>
> This is nice but the width of the bars varies per area since the number
> of stations investigated per area is different, i.e. the more stations
> in an area, the narrower the bars.
>
> So, I would like to make the following adjustments:
>
> - I want to have a fixed bar width regardless of the number of stations
> in each area
> - For the labels on the x axis, I would like to have the stations first,
> and below the area
>
> Can someone help me?
I don't know how to modify your code to do exactly what you want,
but have you considered variations on:
# facet_wrap on area
ggplot(dataset,
aes(y=var,x=station))+geom_bar(stat="identity")+facet_wrap(~area)+scale_y_continuous("Sediment
depth averaged TOM
(%)\n",limits=c(0,8),expand=c(0,0))+scale_x_discrete("Station")
or
# fill by area
ggplot(dataset,
aes(y=var,x=paste(area,station,sep=""),fill=area))+geom_bar(stat="identity")+scale_y_continuous("Sediment
depth averaged TOM
(%)\n",limits=c(0,8),expand=c(0,0))+scale_x_discrete("Station",labels=station)
This does have fixed width, but does not have the area-over-station
labeling (which is redundant using these graphs).
Ron.