繁体   English   中英

如何在 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

上面的代码给了我以下内容:情节1

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

情节2

任何想法来解决它?

使用autorange = "reversed"

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

历史

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM