Plotly:如何增加 Y 轴的宽度?

3
我想要增加plotly水平条形图中Y轴的宽度。目前,由于Y轴太窄,文本会从图表上掉落。
您可以在Plotly的示例页面上看到同样的情况,其中类别不易阅读。
我找不到增加宽度的方法。非常感谢您的帮助!
示例代码:
library(plotly)
p <- plot_ly(x = c(20, 14, 23), 
  y = c('long string which is not readable', 
    'orangutans (not readable)', 
    'monkeys'), 
  type = 'bar', 
  orientation = 'h')

应该是可以的,因为在这里的用户界面中已经实现了:https://help.plot.ly/axes/#step-8-axis-width - Dendrobates
1个回答

4
Plotly 将其隐藏得很好... 您可以在 x 轴的布局下更改此设置,位于域下方。
以下方法可行:
ax <- list(
        domain = list(0.2, 1)
      )
p <- plot_ly(x = c(20, 14, 23), 
  y = c('long string which is not readable', 
    'orangutans (not readable)', 
    'monkeys'), 
  type = 'bar', 
  orientation = 'h') %>%
layout(xaxis = ax)

一般提示:Plotly有一个在线编辑器,您可以导出包含所有设置的JSON对象。然后,搜索该对象可能有助于找到正确的设置。


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接