【发布时间】:2017-05-17 20:37:25
【问题描述】:
如何在 Plotly 水平条形图的顶部而不是底部显示 x 轴?在顶部和底部显示 x 轴也可以。该图将以 R Shiny 显示,并且必须是 Plotly 而不是 ggplotly。谢谢!
来自https://plot.ly/r/horizontal-bar-charts/的示例:
library(plotly)
plot_ly(x = c(20, 14, 23),
y = c('giraffes', 'orangutans', 'monkeys'),
type = 'bar',
orientation = 'h')
编辑: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")
【问题讨论】: