i am using ggplot2 to create a grouped bar chart. quite happy with is so far. the only problem i have is the space between the bars and the x-axis. can anyone help me how to remove it so that the x-axis intersects with the y-axis at 0? here is the code i have so far
library(ggplot2)
#this creates the table for the data used in the figure, i can't use spaces in the names or it won't work
data <- read.table(text="
predator,juvenile,frequency
uninfected,uninfected,20
uninfected,infected,10
infected,uninfected,16
infected,infected,14", header=TRUE, sep=",")
data
#this changes the order in which the bars are plotted in the figure
data$predator<-factor(data$predator,levels=c("uninfected","infected"))
#this plots the barchart
p<-ggplot(data, aes(x=predator, y=frequency, fill=juvenile)) +
geom_bar(stat="identity",colour="black", position="dodge")+
scale_fill_manual(values = c("#FFFFFF", "#000000"))
p
# this changes the axis lables on the plot and sets up the look of the figure
p+ theme(legend.position = "none",panel.grid.major = element_blank(), panel.grid.minor = element_blank(),
panel.background = element_blank(), axis.line = element_line(colour = "black"))+labs(x="adult",y="frequency of choice")
any help would be great. thanks
edit. i did try the scale continuous command but it removed the line of the y axis which i could not manage to get back. any help please