如何绘制并排绘制的规格表?

问题描述 投票:0回答:1

似乎绘图仪表图与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
r plotly subplot flexdashboard gauge
1个回答
0
投票

域中定义的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

enter image description here

© www.soinside.com 2019 - 2024. All rights reserved.