plotly.figure_factory.create_table

plotly.figure_factory.create_table(table_text, colorscale=None, font_colors=None, index=False, index_title='', annotation_offset=0.45, height_constant=30, hoverinfo='none', **kwargs)

Function that creates data tables.

See also the plotly.graph_objects trace plotly.graph_objects.Table

Parameters
  • | list[list]) text ((pandas.Dataframe) – data for table.

  • colorscale ((str|list[list])) – Colorscale for table where the color at value 0 is the header color, .5 is the first table color and 1 is the second table color. (Set .5 and 1 to avoid the striped table effect). Default=[[0, ‘#66b2ff’], [.5, ‘#d9d9d9’], [1, ‘#ffffff’]]

  • font_colors ((list)) – Color for fonts in table. Can be a single color, three colors, or a color for each row in the table. Default=[‘#000000’] (black text for the entire table)

  • height_constant ((int)) – Constant multiplied by # of rows to create table height. Default=30.

  • index ((bool)) – Create (header-colored) index column index from Pandas dataframe or list[0] for each list in text. Default=False.

  • index_title ((string)) – Title for index column. Default=’’.

  • kwargs – kwargs passed through plotly.graph_objects.Heatmap. These kwargs describe other attributes about the annotated Heatmap trace such as the colorscale. For more information on valid kwargs call help(plotly.graph_objects.Heatmap)

Example 1: Simple Plotly Table

>>> from plotly.figure_factory import create_table
>>> text = [['Country', 'Year', 'Population'],
...         ['US', 2000, 282200000],
...         ['Canada', 2000, 27790000],
...         ['US', 2010, 309000000],
...         ['Canada', 2010, 34000000]]
>>> table = create_table(text)
>>> table.show()

Example 2: Table with Custom Coloring

>>> from plotly.figure_factory import create_table
>>> text = [['Country', 'Year', 'Population'],
...         ['US', 2000, 282200000],
...         ['Canada', 2000, 27790000],
...         ['US', 2010, 309000000],
...         ['Canada', 2010, 34000000]]
>>> table = create_table(text,
...                      colorscale=[[0, '#000000'],
...                                  [.5, '#80beff'],
...                                  [1, '#cce5ff']],
...                      font_colors=['#ffffff', '#000000',
...                                 '#000000'])
>>> table.show()

Example 3: Simple Plotly Table with Pandas

>>> from plotly.figure_factory import create_table
>>> import pandas as pd
>>> df = pd.read_csv('http://www.stat.ubc.ca/~jenny/notOcto/STAT545A/examples/gapminder/data/gapminderDataFiveYear.txt', sep='      ')
>>> df_p = df[0:25]
>>> table_simple = create_table(df_p)
>>> table_simple.show()