Hello,
Attached are my R/ggplot2 code and the bar graph. The code has produced the desired bar graph except that
a) the x-axis values are in different order [panel 16 (topmost) and panel 7 (bottommost)]. I want panel 7 to be the topmost and panel 16 to be the bottommost.
b) the Year 2 bar is followed by Year 1 bar for each panel. I want Year 2 bar to be placed after Year 1 bar when stacked.
Any help with revisions of the code to resolve the above issues would be highly appreciated.
Thanks,
Pradip Muhuri
*********************** part of attachment 1 *****************************
p <- ggplot(data = tempdata, aes(x = add_col, y = est, ymin=0, ymax=8,
fill = spd)) +
geom_bar(position="dodge", stat="identity", width=0.50) +
geom_text (aes(label=formatC(tempdata$est, format="f", digits=1)),
position=position_dodge(width=0.9),
hjust=-.1, vjust=.4, colour="red", size=8) +
scale_fill_manual(values=c("black", "#996633"))+
labs (x = " ", y= "Average # of Ambulatory Visits", fill=" ")+
ylim (0,8)+
coord_flip()+
theme(text = element_text(size = 25, face = "bold"),
axis.text.x = element_text(vjust = 0, colour="black"),
axis.text.y = element_text(hjust = 1, colour="black"),
axis.title.y = element_text(size = rel(0.4), colour="black"),
axis.title.x = element_text( face = "plain"),
legend.text = element_text(size = rel(0.8), hjust = 0),
legend.position = "bottom")+
guides(fill = guide_legend(reverse=TRUE))
print (p)
ggsave(file='amb_visits_by_yr_in_panel.png', width=11, height=7)