1

I am currently trying to create a bar plot, in which some variables have 2 levels and some just one. As I am using dodged bars this results in the single level bars not being centered (see figure).

Current plot I would like the "single" bars (e.g. B4) to be placed on the center of the variable name (not below). This is the code I have created so far:

t <- ggplot(data=test, aes(x=reorder(name,-auc), y=auc, fill=sensor)) +
  geom_bar(stat="identity", position = position_dodge(width=0.6,preserve, "single"),width = 0.5)

Thanks for your support.

user28724
  • 115
  • 1
  • 1
  • 11
  • You may want to use `position_dodge2` instead of `position_dodge`. (& if that doesn't work, consider making your problem [reproducible](https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example) by including the output of `dput(test)` in your question). – Z.Lin Apr 16 '19 at 09:58
  • Also, it should be `preserve = "single"` rather than `preserve, "single"`. – Z.Lin Apr 16 '19 at 09:59

0 Answers0