Skip to content

API Reference

Collection of functions to plot and save a pd.DataFrame.

plot_dataframe

plot_dataframe(df, *, print_index=True, title=None, tbl_header_visible=True, tbl_header=None, tbl_cells=None, row_fill_color=None, col_width=None, fig_size=None, show_fig=True, plotly_renderer='png', **layout_kwargs)

Plot a pd.Series or pd.DataFrame.

Parameters:

Name Type Description Default
df Series | DataFrame

Series or dataframe to be plotted.

required
print_index bool

If True, prints the dataframe's index. df.index.name will become the index column header.

True
title dict | None

A dict possibly containing plotly key/value pairs:

https://plotly.com/python/reference/layout/#layout-title

More relevant key/value pairs:

  • font_color : color
  • font_family : str
  • font_size : number greater than or equal to 1
  • text : str
  • x : number between or equal to 0 and 1, default 0.5

Sets the x position with respect to xref in normalized coordinates from "0" (left) to "1" (right).

  • xanchor : enumerated, one of ("auto", "left", "center", "right"), default "auto"

Sets the title's horizontal alignment with respect to its x position. "left" means that the title starts at x, "right" means that the title ends at x and "center" means that the title's center is at x. "auto" divides xref by three and calculates the xanchor value automatically based on the value of x.

None
tbl_header_visible bool

If False, table header will be invisible. Takes precedence over tbl_header argument.

True
tbl_header dict | None

A dict possibly containing plotly key/value pairs:

https://plotly.com/python/reference/table/#table-header

https://plotly.com/python/reference/table/#table-cells

More relevant key/value pairs:

  • align : enumerated or array of enumerateds, one of ("left", "center", "right"), default "center"
  • fill_color : color, default "white"
  • font_color : color or array of colors
  • font_family : str or array of str
  • font_size : number or array of numbers greater than or equal to 1
  • height : number, default 28
  • line_width : number or array of numbers, default 1
None
tbl_cells dict | None

A dict possibly containing plotly key/value pairs:

https://plotly.com/python/reference/table/#table-header

https://plotly.com/python/reference/table/#table-cells

More relevant key/value pairs:

  • align : enumerated or array of enumerateds, one of ("left", "center", "right"), default "center"
  • fill_color : color, default "white"
  • font_color : color or array of colors
  • font_family : str or array of str
  • font_size : number or array of numbers greater than or equal to 1
  • height : number, default 28
  • line_width : number or array of numbers, default 1
None
row_fill_color tuple[str, str] | None

Tuple of colors that will be used to alternate row colors. Takes precedence over tbl_cells["fill_color"].

None
col_width float | list[int | float] | None

The width of columns expressed as a ratio. Columns fill the available width in proportion of their specified column widths.

None
fig_size tuple[int, int] | None

Tuple specifying the width and height of the figure.

None
show_fig bool

If True, plot will be displayed.

True
plotly_renderer str

Option to specify how and where to display the figure. See https://plotly.com/python/renderers/ for further information.

'png'
**layout_kwargs Any

Plotly accepts a large number of layout-related keyword arguments. A detailed descriptions is available at https://plotly.com/python-api-reference/generated/plotly.graph_objects.Layout.html.

{}

Returns:

Type Description
Figure

Returns a figure object.

save_dataframe

save_dataframe(fig, filename)

Write plotly figure to disk.

Parameters:

Name Type Description Default
fig Figure

Figure object to save.

required
filename Path

Filename including path where to save figure.

required

Returns:

Type Description
None