I am trying to plot the following dataframe with ggplot2, but I have several issues. Also, the visual aspect doest not seem very nice
selectedResDF <- data.frame(protocol=character(), run=character(), x=character(), y=double(), sd=double())
selectedResDF
protocol run x y sd
1 DDelivery B 300 0.05063383 2.009576e-04
2 DDelivery C 600 0.05064577 8.512595e-05
3 DDelivery D 900 0.05065898 1.027849e-04
4 DDelivery A 7200 0.05066435 1.505408e-04
21 Epidemic B 300 0.73445680 8.737406e-03
22 Epidemic C 600 0.80729300 3.713654e-03
23 Epidemic D 900 0.80729514 6.705972e-03
24 Epidemic A 7200 0.80680767 5.182245e-03
pd <- position_dodge(0.05)
oneCfgPlot <- ggplot(selectedResDF, aes(x=selectedResDF$x, y=selectedResDF$y, group=selectedResDF$protocol, colour=selectedResDF$protocol)) + geom_errorbar(aes(ymin=selectedResDF$y-selectedResDF$sd, ymax=selectedResDF$y+selectedResDF$sd), color="black", width=.1, position=pd) + geom_line(position=pd) + geom_point(position=pd, size=3, shape=21, fill="white")
print(oneCfgPlot)
Issues
1- The X axis is discrete, this is why i define it as character, while my data is organized as following (300,600,900,7200), when ploting the X axis is reordered as following (300,600,7200, 900), How to maintain the previous order ?
2- Error bars are not correctly aligned on value, sometimes going more to the left or the right, how can i fix it ?
3- How can I combine correctly geom_line and geom_point to get one colour and one single point shape for each drawn line ?
Thanks!