似乎 plotly 仪表图表与 subplot
不兼容因为我最终得到了两个相互叠加的仪表图。
library(plotly)
fig1 <- plot_ly(
domain = list(x = c(0, 1), y = c(0, 1)),
value = 270,
title = list(text = "Speed"),
type = "indicator",
mode = "gauge+number")
fig1 <- fig1 %>%
layout(margin = list(l=20,r=30))
fig1
fig2 <- plot_ly(
domain = list(x = c(0, 1), y = c(0, 1)),
value = 50,
title = list(text = "Speed"),
type = "indicator",
mode = "gauge+number")
fig2 <- fig2 %>%
layout(margin = list(l=20,r=30))
fig2
fig <- subplot(fig1,fig2)
fig
最佳答案
域中定义的 x 和 y 值会覆盖任何其他布局选项。
使用 x 和 y 定义来指定仪表位置:
library(plotly)
fig1 <- plot_ly(
domain = list(x = c(0, 0.45), y = c(0, 1)),
value = 270,
title = list(text = "Speed"),
type = "indicator",
mode = "gauge+number")
fig1 <- fig1 %>% layout(margin = list(l=20,r=30))
fig2 <- plot_ly(
domain = list(x = c(0.55, 1), y = c(0, 1)),
value = 50,
title = list(text = "Speed"),
type = "indicator",
mode = "gauge+number")
fig2 <- fig2 %>% layout(margin = list(l=20,r=30))
fig <- subplot(fig1, fig2)
fig
关于r - 如何绘制彼此相邻的绘图仪表图?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61164966/