如何为 R Plotly 添加标题 table

How to add a title to a R Plotly table

我使用 ropensci/plotly 库创建了一个 table。我尝试了几种方法来添加标题。

这是我的代码:

library(plotly)
data <- read.csv("data.csv")

plot_ly(

type = 'table',
columnwidth = c(33, 32, 32),
columnorder = c(0, 1, 2),
header = list(
  values = list(list(c("1st column")),
                list(c("2nd column")),
                list(c("3rd column"))
  ),
  align = c("center", "center"),
  line = list(width = 2, color = 'black'),
  fill = list(color = c("blue", "blue")),
  font = list(family = "Arial", size = 14, color = "white")
),
cells = list(
  values = list(c(datast_column),c(datand_column),c(datard_column)),
  align = c("center", "center"),
  line = list(color = "black", width = 1),
  font = list(family = "Arial", size = 12, color = c("black"))
))

我发现添加:

%>%
layout(title = "Text Title")

在最后一个“))”之后,您的标题将显示在您的图表上方。

这是我遇到的问题,无法在 R 中找到 'title' 图表的答案,所以我想我会 post 它。