How to Create Tables in Plotly Python?

Spread the love

To create a Table in Plotly Python, we can use the go.Table function. go.Table provides a Table object for detailed data viewing. The data are arranged in a grid of rows and columns. Most styling can be specified for header, columns, rows or individual cells.

Basic Table –

Let’s create a basic table which shows marks of students.

import plotly.graph_objects as go

fig = go.Figure(data=[go.Table(header=dict(values=['Name', 'Marks']),
                                    [95, 80, 75, 85, 80]]))])

Styled Table –

We can also style the table.

fig = go.Figure(data=[go.Table(
    header=dict(values=['Name', 'Marks'],
                       [95, 80, 75, 85, 80]],

Create a Table from Pandas DataFrame –

Let’s read a dataframe and see how to create a table from it.

import pandas as pd
url = ''
df = pd.read_csv(url)

Now, Let’s visualize this dataframe in plotly table.

fig = go.Figure(data=[go.Table(
    cells=dict(values=[df['Customer'], df['Type of Customer'], df['Items'], 
                       df['Net Sales'], df['Method of Payment'],
                      df['Gender'],df['Marital Status'], df['Age']],

Related Posts –

  1. How to install plotly python with pip?
  2. How to create a Line Chart with Plotly Python?
  3. How to create Scatter plot in Plotly Python?
  4. How to create a Bar Chart in Plotly Python?
  5. How to create Horizontal Bar Chart in Plotly Python?
  6. How to create a Histogram in plotly python?
  7. How to Create a Box Plot in Plotly Python?
  8. How to create a Pie Chart in Plotly Python?
  9. How to create a Dot Plot in Plotly Python?
  10. How to Create Heatmap with Plotly Python?
  11. How to Create a Violin Plot in Plotly Python?
  12. How to Create Subplots in Plotly Python?
  13. How to Create a Bubble Chart in Plotly Python?
  14. How to Create a Gantt Chart in Plotly Python?
  15. How to Create an Area Chart in Plotly Python?

Rating: 1 out of 5.

Leave a Reply