Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to add a title to a R Plotly table

Tags:

r

plotly

I have created a table using the ropensci/plotly library. I have tried to add a title several ways.

Here is my code:

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(data$1st_column),c(data$2nd_column),c(data$3rd_column)),
  align = c("center", "center"),
  line = list(color = "black", width = 1),
  font = list(family = "Arial", size = 12, color = c("black"))
))
like image 342
sectechguy Avatar asked Oct 23 '25 16:10

sectechguy


1 Answers

I have found that adding:

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

to the very end after the last "))" your title will show above your chart.

This is something I was having trouble with and couldn't find an answer for the 'title' chart in R, so I figured I'd post it.

like image 200
sectechguy Avatar answered Oct 26 '25 06:10

sectechguy