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()