I have a dataset which includes data from 100 simulations of train runs in a network with 4 trains, 6 stations and lateness at arrival for each train at each station. My data lo
This?
ggplot(MyData, aes(factor(Stations), Arrival_Lateness,
fill = factor(Train_number))) +
stat_summary(fun.data = f, geom="boxplot",
position=position_dodge(1))+
stat_summary(aes(color=factor(Train_number)),fun.y = q, geom="point",
position=position_dodge(1))
IMHO this is a little easier to interpret.
ggplot(MyData, aes(factor(Train_number), Arrival_Lateness,
fill = factor(Train_number))) +
stat_summary(fun.data = f, geom="boxplot",
position=position_dodge(1))+
stat_summary(aes(color=factor(Train_number)),fun.y = q, geom="point",
position=position_dodge(1))+
facet_grid(.~Stations, scales="free")+
theme(axis.text.x=element_text(angle=-90,hjust=1,vjust=0.2))+
labs(x="Train Number")
EDIT (Response to OP's comment)
ggplot(MyData, aes(factor(Train_number), Arrival_Lateness,
fill = factor(Train_number))) +
stat_summary(fun.data = f, geom="boxplot",
position=position_dodge(1))+
stat_summary(aes(color=factor(Train_number)),fun.y = q, geom="point",
position=position_dodge(1))+
facet_grid(.~Stations, scales="free")+
theme(axis.text.x=element_blank(), axis.ticks.x=element_blank())+
scale_fill_discrete("Train")+scale_color_discrete("Train")+
labs(x="")
To turn off x-axis text and tick marks, us theme(...=element_blank())
. To turn off the axis label, use labs(x="")
. Also, the fill and color scales have to have the same name, or they display separately.