1

I am trying to plot a horizontal barplot with the ggbarplot function (ggpubr package), and this is what I have so far:

enter image description here =

There are a couple of things that I want to change. First of all I would like to have more space in between the vertical axis labels, so the barplot would have to become longer in a sense.

Second, I would like the label for the 'negative bars' to be on the left hand side, similarly to the labels for the 'positive bars' that are on the RHS.

This is the code that I wrote for the figure that I have now, where graph_data contains all the data.

ggbarplot(graph_data, x = "name" , y = "cum_r",
       fill = "grp",           # change fill color by mpg_level
      color = "White",            # Set bar border colors to white
      palette = c("red", "green"),             
      sort.val = "asc",          # Sort the value in descending order
      sort.by.groups = FALSE,     # Don't sort inside each group
      x.text.angle = 90,          # Rotate vertically x axis texts
      ylab = "Cumulative return (%)",
      xlab = "Keyword",
      legend.title = "Return",
      rotate = TRUE,
      lab.nb.digits = 2,
      ggtheme = theme_classic(),
      label=TRUE, lab.pos = "out", lab.col = "black",
      lab.size=2,
      lab.vjust = 0.5,
      lab.hjust = -0.5)
John
  • 555
  • 3
  • 16
  • You need to share your data so others can help. [How to make a great R reproducible example?](https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example) – Tung May 26 '18 at 08:29
  • For me, the first hit when searching for [space between bars ggplot2](https://www.ecosia.org/search?q=space+between+bars+ggplot2&addon=chrome&addonversion=2.0.3) yields a solution. – Roman Luštrik May 26 '18 at 08:29
  • Your first question seems to be answered here: [How to enlarge my plot width in ggplot2?](https://stackoverflow.com/questions/29587881/how-to-enlarge-my-plot-width-in-ggplot2). Please ask one question at a time. – Henrik May 26 '18 at 08:58
  • @Tung it's a lot of data, so it would become really messy I think. But you're right, I should've made a simpler example. Thank you Roman and Henrik, I managed to do the first question! – John May 26 '18 at 09:16

0 Answers0