plotly.R icon indicating copy to clipboard operation
plotly.R copied to clipboard

in bar plot bars are in the wrong order

Open skostiaev opened this issue 3 years ago • 0 comments

Please briefly describe your problem and what output you expect. If you have a question, please don't use this form, but instead ask on the community forum http://community.plot.ly/c/api/r or stackoverflow http://stackoverflow.com.

Please include a minimal reprex. The goal of a reprex is to make it as easy as possible for me to recreate your problem so that I can fix it. If you've never heard of a reprex before, start by reading https://github.com/tidyverse/reprex#readme, and follow the advice further down the page. Do NOT include session info unless it's explicitly asked for, or you've used reprex::reprex(..., si = TRUE) to hide it away.

Delete these instructions once you have read them.


Brief description of the problem bar named 3 months must follow bar named "ban". currently, it is between 12 and 6 month bar


library(plotly)
fig <- plot_ly()
fig <- fig %>% add_bars(
  x = c("12 months", "6 months", "3 months","ban on short term plans" ),
  y = c(-200),
  base = c(0),
  marker = list(
    color = 'red'
  ),
)
fig <- fig %>% add_bars(
  x = c("12 months", "6 months", "3 months","ban on short term plans"),
  y = c(-76, -61, -44,-121),
  base = c(0),
  marker = list(
    color = 'grey'
  ),
  name = 'decrease in premiums'
)
fig

skostiaev avatar Sep 13 '22 14:09 skostiaev