Function that creates data tables. See also the plotly.graph_objects trace :class:`plotly.graph_objects.Table` :param (pandas.Dataframe | list[list]) text: data for table. :param (str|list[list]) colorscale: Colorscale for table where the color at value 0 is the header
(
table_text,
colorscale=None,
font_colors=None,
index=False,
index_title="",
annotation_offset=0.45,
height_constant=30,
hoverinfo="none",
**kwargs,
)
| 23 | |
| 24 | |
| 25 | def create_table( |
| 26 | table_text, |
| 27 | colorscale=None, |
| 28 | font_colors=None, |
| 29 | index=False, |
| 30 | index_title="", |
| 31 | annotation_offset=0.45, |
| 32 | height_constant=30, |
| 33 | hoverinfo="none", |
| 34 | **kwargs, |
| 35 | ): |
| 36 | """ |
| 37 | Function that creates data tables. |
| 38 | |
| 39 | See also the plotly.graph_objects trace |
| 40 | :class:`plotly.graph_objects.Table` |
| 41 | |
| 42 | :param (pandas.Dataframe | list[list]) text: data for table. |
| 43 | :param (str|list[list]) colorscale: Colorscale for table where the |
| 44 | color at value 0 is the header color, .5 is the first table color |
| 45 | and 1 is the second table color. (Set .5 and 1 to avoid the striped |
| 46 | table effect). Default=[[0, '#66b2ff'], [.5, '#d9d9d9'], |
| 47 | [1, '#ffffff']] |
| 48 | :param (list) font_colors: Color for fonts in table. Can be a single |
| 49 | color, three colors, or a color for each row in the table. |
| 50 | Default=['#000000'] (black text for the entire table) |
| 51 | :param (int) height_constant: Constant multiplied by # of rows to |
| 52 | create table height. Default=30. |
| 53 | :param (bool) index: Create (header-colored) index column index from |
| 54 | Pandas dataframe or list[0] for each list in text. Default=False. |
| 55 | :param (string) index_title: Title for index column. Default=''. |
| 56 | :param kwargs: kwargs passed through plotly.graph_objs.Heatmap. |
| 57 | These kwargs describe other attributes about the annotated Heatmap |
| 58 | trace such as the colorscale. For more information on valid kwargs |
| 59 | call help(plotly.graph_objs.Heatmap) |
| 60 | |
| 61 | Example 1: Simple Plotly Table |
| 62 | |
| 63 | >>> from plotly.figure_factory import create_table |
| 64 | |
| 65 | >>> text = [['Country', 'Year', 'Population'], |
| 66 | ... ['US', 2000, 282200000], |
| 67 | ... ['Canada', 2000, 27790000], |
| 68 | ... ['US', 2010, 309000000], |
| 69 | ... ['Canada', 2010, 34000000]] |
| 70 | |
| 71 | >>> table = create_table(text) |
| 72 | >>> table.show() |
| 73 | |
| 74 | Example 2: Table with Custom Coloring |
| 75 | |
| 76 | >>> from plotly.figure_factory import create_table |
| 77 | >>> text = [['Country', 'Year', 'Population'], |
| 78 | ... ['US', 2000, 282200000], |
| 79 | ... ['Canada', 2000, 27790000], |
| 80 | ... ['US', 2010, 309000000], |
| 81 | ... ['Canada', 2010, 34000000]] |
| 82 | >>> table = create_table(text, |
no test coverage detected