我在一个 Shiny 的应用程序中有一些 googleVis 图表,但是当它们太长时,googleVis 默认会缩短水平轴上的标签。我该如何防止这种行为?下面的示例复制了我想阻止的行为:
df=data.frame(country=c(paste(rep("very very long label", 1e+2)), "GB", "BR"),
val1=c(10,13,14),
val2=c(23,12,32))
Line <- gvisLineChart(df)
plot(Line)
文档的链接是 here
最佳答案
如果你问 Google 同样的问题,这总是一件棘手的事情。但我发现了一个显示 x 标签的“技巧”,这是我的解决方法:
更改图表区域:上方的“填充”占据下方 hAxis 的空间。
在 R 中,可以通过 gvisLineChart()
函数中的 options
参数实现这一点。
Line <- gvisLineChart(df,
options = list(chartArea =
"{'width': '82%', height: '60%', top: '9%', right: '3%', bottom: '90'}"))
plot(Line)
当然,您必须根据需要调整这些值。也许这种方法对您有帮助。
关于r - 如何防止 googleVis 缩短标签?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39824123/