You can control the order that the items in the legend are displayed by
using the breaks argument of scale_fill_discrete:
ggplot(example.data, aes(x = issue.name, fill = issue.answer)) +
geom_bar(position = "dodge") + coord_flip() +
scale_fill_discrete(breaks=c("Yes","Not Sure","No Response","No"))
> Does anyone have a suggestion on how to flip the order of the bars or
> a better way to display the data?
A hackish way to flip the order of the bars (relative to the order in
the legend) is to dodge them negatively:
ggplot(example.data, aes(x = issue.name, fill = issue.answer)) +
geom_bar(position = position_dodge(width=-0.9)) + coord_flip()
The 0.9 is empirically determined; I tried different values starting at
-1 and adjusted until it looked right. I don't know if negative dodging
is supposed to work, but I've used it for this purpose before.
> Thanks,
--
Brian S. Diggs, PhD
Senior Research Associate, Department of Surgery
Oregon Health & Science University
You can control the order of the entries in the legend using the breaks
argument to scale_fill_discrete:
ggplot(example.data, aes(x = issue.name, fill = issue.answer)) +
geom_bar(position = "dodge") + coord_flip() +
scale_fill_discrete(breaks=c("Yes","Not Sure","No Response","No"))
> Does anyone have a suggestion on how to flip the order of the bars or
> a better way to display the data?
>
> Thanks,
>