I want to plot the data provided in dput using ggplot. I have tried using the code below but the error bars have overlapped. How could I plot the data with out overlap with firm or cat on x-axis and anyone of them dodged?
ggplot(df, aes(x = Firm, y = percent, ymin = lcl, ymax = ucl)) + geom_linerange(position=position_dodge(width=0.60)) + geom_point( size =3.5) + ylab("Percent Gains") + geom_hline(aes(yintercept = 0)) + xlab("Centers") + theme(axis.title=element_text(face="bold",size="12", color="blue"))
Reproducible data
structure(list(percent = c(0.487949245610619, 3.27880172100063, 1.89374877194499, 1.08252115508014, -0.692103184183268, 0.198063556460548, 1.09332951525736, 0.496686952250625, -0.105000620319717, 0.217630052057594, 0.492752135462715, 2.06742921702474, 2.19736131810619, -0.461142997846875, -0.511557523071016), lcl = c(-0.982462000903261, 0.394631092930098, -0.639589178155431, -1.80976900249697, -4.09482382314923, -0.677573402424136, -0.73224708845242, -1.00644816951001, -1.68416496187449, -2.1287716444072, -0.440412399860468, -0.00113831891449534, 0.443323691248554, -1.96785109024255, -2.95893935853256), ucl = c(1.98019611112259, 6.24582977004349, 4.49167785161435, 4.06000657363825, 2.8313461600352, 1.08142022286779, 2.95247925665045, 2.02264593629817, 1.49952850623303, 2.62028526667761, 1.43466315187299, 4.1787869565604, 3.98202963183645, 1.06872249037189, 1.99754744081631), cat = c("UPS", "UPS", "UPS", "UPS", "UPS", "DP", "DP", "DP", "DP", "DP", "RM", "RM", "RM", "RM", "RM"), Firm = c("BA", "RM", "BM", "MU", "MC", "BA", "RM", "BM", "MU", "MC", "BA", "RM", "BM", "MU", "MC")), .Names = c("percent", "lcl", "ucl", "cat", "Firm"), row.names = c("1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14", "15"), class =
"data.frame")
Thanks
Dear Ben,
Thousand hanks for your input. I have produced non-overlapping error bars. But I need some help on the following. I am absolute beginner for ggplot and doing my best to learn , so bear with me.
1. In the present stand the three error bars are not identifiable, it is impossible to know which bar belongs to which cat. How could I overcome that?
2. The font for axes are small, especially the fonts for firm. How can I modify that ?
3. Finally how can I modify the background? It is a bit dark.
Many thanks