I have the following data:
thedata <- data.frame(value= c(90,100,2,10)
,category1 = c("A","A","B","B")
,category2 = c("C","D","C","D"))
And I am looking to produce the following figure with labels just to the outside of the bars:
ggplot(thedata, aes(x=category2, y=value)) +
geom_bar(stat="identity", position="dodge", fill = "grey") +
facet_wrap(~category1, scales = "free_x") +
coord_flip() +
geom_text(aes(label=value, hjust = -0.35))
Using this method the labels fall outside the chart range. If the expand_limits
argument is used it overwrites the scales = "free_x"
argument. Any suggestions for say, adding an extra 10% space to each of the chart to accommodate the labels?