I already browsed a lot, but unfortunately I just find vague information. I want to display a sex ratio over length classes. To achieve that I did a stacked barplot with ggplot2 (geom_bar). This is the code:
Data <- data.frame(LCnew=c(30,30,31,31,32,32,33,33,34,34,35,35,36,36,37,37,38,38,39,39,40,40),
sex=c(1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2))
ggplot(Data, aes(x=factor(LCnew), fill=factor(sex)))+geom_bar(position="fill") + scale_x_discrete("Lengthclass [mm]") + scale_y_continuous("Proportion of sexes") + scale_fill_manual(values=cols)
cols is just a simple vector with colours in it.
This is the plot so far:
My problem is that I am not able to change the axis text. I just want text below every fifth bar, otherwise they are overlapping. I tried it with the limits and breaks command, but this just gave me an empty graph.
scale_x_continuous("Standard Length [mm]",limits=c(30,85),breaks=c(30,35,40,45,50,55,60,65,70,75,80,85))
Any suggestions?