You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何修改Plotly仪表盘指标图的最大值(示例当前最大值为30)

修改Plotly仪表盘最大值的方法

要调整这个仪表盘的最大值,只需在plot_ly()的参数中添加gauge配置项,通过axis下的range参数指定数值区间即可。

比如要将最大值改为50,修改后的代码如下:

library(plotly)

fig <- plot_ly(
  domain = list(x = c(0, 1), y = c(0, 1)),
  value = 20,
  title = list(text = "Speed"),
  type = "indicator",
  mode = "gauge+number",
  # 自定义仪表盘数值范围,第一个值是最小值,第二个是最大值
  gauge = list(axis = list(range = c(0, 50)))
 )
fig <- fig %>%
  layout(margin = list(l=2,r=3))

fig

你可以根据需求替换range里的第二个数值为任意想要的最大值,最小值也能按需调整(比如想从10到80,就写c(10, 80))。

内容的提问来源于stack exchange,提问作者Sebastian SEO

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.15 16:18:09