在 R Shiny 中的绘图顶部显示 X 轴而不是底部?

Jus*_*yer 2 r shiny plotly

如何在 Plotly 水平条形图的顶部而不是底部显示 x 轴?在顶部和底部显示 x 轴也可以。该图将显示在 R Shiny 中,并且必须是 Plotly 而不是 ggplotly。谢谢!

来自https://plot.ly/r/horizo​​ntal-bar-charts/ 的示例:

library(plotly)
plot_ly(x = c(20, 14, 23), 
y = c('giraffes', 'orangutans', 'monkeys'), 
type = 'bar', 
orientation = 'h')
Run Code Online (Sandbox Code Playgroud)

编辑:HubertL 提供了一个解决方案(谢谢!),将 x 轴放在顶部,但随后与图表标题重叠。我没有指定我正在使用标题的错。有没有办法让 x 轴标题和 x 轴刻度不与情节标题重叠?

plot_ly(x = c(20, 14, 23), 
        y = c('giraffes', 'orangutans', 'monkeys'), 
        type = 'bar', 
        orientation = 'h') %>%
   layout(xaxis = list(side ="top", 
          title = "EXAMPLE X AXIS TITLE"), 
          title = "EXAMPLE PLOT TITLE")
Run Code Online (Sandbox Code Playgroud)

在此处输入图片说明

Hub*_*rtL 7

您可以side ="top"layout.xaxis

plot_ly(x = c(20, 14, 23), 
        y = c('giraffes', 'orangutans', 'monkeys'), 
        type = 'bar', 
        orientation = 'h') %>%
  layout(xaxis = list(side ="top" ) ) 
Run Code Online (Sandbox Code Playgroud)

在此处输入图片说明