Black Lives Matter. Please consider donating to Black Girls Code today.
Learn how to use COVID-19 data in open source Dash apps. Register for the Sept 23rd webinar with IQT!

Up x coordinate in horizontal barplot (R)


I ask a question about how to change graphic elements position in the barplot of plotly package.

I want to change the display of the x coordinate

in barplot, moving from bottom to top, to enhance visualization.

The attached image explains better.

I wonder if it is possible, and if you can send me an example showing how to make.

If I understand correctly, something like this should achieve the desired result.


mtcars %>%
  plot_ly() %>%
    x=~mpg, y=~rownames(mtcars),
  ) %>%

If you are not yet using the development version of plotly, then you can just append the %>% layout(xaxis=list(side="top")) to your code and ignore the potentially confusing ~.

1 Like

Thank you, that was exactly what I wanted.