【发布时间】:2019-10-09 13:15:44
【问题描述】:
我不知道如何使用 R 和 Plotly 使表格子图正常工作。
以下说明了我的意思。我有两个图,一个散点图和一个表。使用 subplot 函数,表格图的行为与预期不符。
我要么失去散点图的交互性,要么有重叠的散点图/表格图。如果我遗漏了什么或者这是一个错误,请告诉我。
我正在使用 plotly 4.9.0 版
提前致谢!
library(plotly)
df <- data.frame(x = 1:10,
y = 1:10)
p1 <-
plot_ly(data = df,
type = "scatter",
mode = "line",
x = ~x,
y = ~y) %>%
layout(xaxis = list(fixedrange=T),
yaxis = list(fixedrange=T)) %>%
config(displayModeBar = F)
p2 <-
plot_ly(
type = 'table',
header = list(values = c("x", "y")),
cells = list(values = rbind(df$x, df$y))
)
subplot(p1, p2, nrows = 2) # overlapping plots
subplot(p2, p1, nrows = 2) # loses interactivity on p2
subplot(p1, p1, nrows = 2) # works as expected
【问题讨论】: