Skip to main content

How do I add Plotly or Bokeh Charts into Tables?

Direct integration of Plotly or Bokeh figures into tables is not supported. Instead, export the figures to HTML and include the HTML in the table. Below are examples demonstrating this with interactive Plotly and Bokeh charts.

import wandb
import plotly.express as px

# Initialize a new run
run = wandb.init(project="log-plotly-fig-tables", name="plotly_html")

# Create a table
table = wandb.Table(columns=["plotly_figure"])

# Define path for Plotly figure
path_to_plotly_html = "./plotly_figure.html"

# Create a Plotly figure
fig = px.scatter(x=[0, 1, 2, 3, 4], y=[0, 1, 4, 9, 16])

# Export Plotly figure to HTML
# Setting auto_play to False prevents animated Plotly charts from playing automatically
fig.write_html(path_to_plotly_html, auto_play=False)

# Add Plotly figure as HTML file to the table
table.add_data(wandb.Html(path_to_plotly_html))

# Log Table
run.log({"test_table": table})
wandb.finish()
Was this page helpful?๐Ÿ‘๐Ÿ‘Ž