如何在 R 中使用 Plotly 翻转 x 轴(180 度)

How can I flip the x axis (180 degrees) using Plotly in R

我使用以下代码创建了概率直方图:

set.seed(99)
x <- rnorm(1000)
fig1 <- plot_ly (y = ~x, type = 'histogram', histnorm = 'probability') %>% 
        layout(title = "Frequency Distribution",
               xaxis = list(title = "Frequency", mirror = TRUE  ))
fig1

上面的代码给出了以下内容:

从代码中可以看出,我尝试在 xaxis 部分使用 mirror 将绘图翻转 180 度。但是,它不起作用。我想要这样的情节:

有什么解决办法吗?

使用autorange = "reversed"

plot_ly (y = ~x, type = 'histogram', histnorm = 'probability') %>% 
  layout(
    title = "Frequency Distribution",
    xaxis = list(title = "Frequency", autorange = "reversed")
  )