plotly.basedatatypes.BaseFigure

class plotly.basedatatypes.BaseFigure(data=None, layout_plotly=None, frames=None, skip_invalid=False, **kwargs)

Base class for all figure types (both widget and non-widget)

__init__(data=None, layout_plotly=None, frames=None, skip_invalid=False, **kwargs)

Construct a BaseFigure object

Parameters
  • data

    One of: - A list or tuple of trace objects (or dicts that can be coerced into trace objects)

    • If data is a dict that contains a ‘data’,

    ’layout’, or ‘frames’ key then these values are used to construct the figure.

    • If data is a BaseFigure instance then the data, layout,

    and frames properties are extracted from the input figure

  • layout_plotly

    The plotly layout dict.

    Note: this property is named layout_plotly rather than layout to deconflict it with the layout constructor parameter of the widgets.DOMWidget ipywidgets class, as the BaseFigureWidget class is a subclass of both BaseFigure and widgets.DOMWidget.

    If the data property is a BaseFigure instance, or a dict that contains a ‘layout’ key, then this property is ignored.

  • frames

    A list or tuple of plotly.graph_objects.Frame objects (or dicts that can be coerced into Frame objects)

    If the data property is a BaseFigure instance, or a dict that contains a ‘frames’ key, then this property is ignored.

  • skip_invalid (bool) – If True, invalid properties in the figure specification will be skipped silently. If False (default) invalid properties in the figure specification will result in a ValueError

Raises

ValueError – if a property in the specification of data, layout, or frames is invalid AND skip_invalid is False

Methods

__init__([data, layout_plotly, frames, …])

Construct a BaseFigure object

add_hline(y[, row, col, exclude_empty_subplots])

Add a horizontal line to a plot or subplot that extends infinitely in the x-dimension.

add_hrect(y0, y1[, row, col, …])

Add a rectangle to a plot or subplot that extends infinitely in the x-dimension.

add_trace(trace[, row, col, secondary_y, …])

Add a trace to the figure

add_traces(data[, rows, cols, secondary_ys, …])

Add traces to the figure

add_vline(x[, row, col, …])

Add a vertical line to a plot or subplot that extends infinitely in the y-dimension.

add_vrect(x0, x1[, row, col, …])

Add a rectangle to a plot or subplot that extends infinitely in the y-dimension.

append_trace(trace, row, col)

Add a trace to the figure bound to axes at the specified row, col index.

batch_animate([duration, easing])

Context manager to animate trace / layout updates

batch_update()

A context manager that batches up trace and layout assignment operations into a singe plotly_update message that is executed when the context exits.

for_each_trace(fn[, selector, row, col, …])

Apply a function to all traces that satisfy the specified selection criteria

full_figure_for_development([warn, as_dict])

Compute default values for all attributes not specified in the input figure and returns the output as a “full” figure.

get_subplot(row, col[, secondary_y])

Return an object representing the subplot at the specified row and column.

plotly_relayout(relayout_data, **kwargs)

Perform a Plotly relayout operation on the figure’s layout

plotly_restyle(restyle_data[, trace_indexes])

Perform a Plotly restyle operation on the figure’s traces

plotly_update([restyle_data, relayout_data, …])

Perform a Plotly update operation on the figure.

pop(key, *args)

Remove the value associated with the specified key and return it

print_grid()

Print a visual layout of the figure’s axes arrangement.

select_traces([selector, row, col, secondary_y])

Select traces from a particular subplot cell and/or traces that satisfy custom selection criteria.

set_subplots([rows, cols])

Add subplots to this figure.

show(*args, **kwargs)

Show a figure using either the default renderer(s) or the renderer(s) specified by the renderer argument

to_dict()

Convert figure to a dictionary

to_html(*args, **kwargs)

Convert a figure to an HTML string representation.

to_image(*args, **kwargs)

Convert a figure to a static image bytes string

to_json(*args, **kwargs)

Convert a figure to a JSON string representation

to_ordered_dict([skip_uid])

to_plotly_json()

Convert figure to a JSON representation as a Python dict

update([dict1, overwrite])

Update the properties of the figure with a dict and/or with keyword arguments.

update_layout([dict1, overwrite])

Update the properties of the figure’s layout with a dict and/or with keyword arguments.

update_traces([patch, selector, row, col, …])

Perform a property update operation on all traces that satisfy the specified selection criteria

write_html(*args, **kwargs)

Write a figure to an HTML file representation

write_image(*args, **kwargs)

Convert a figure to a static image and write it to a file or writeable object

write_json(*args, **kwargs)

Convert a figure to JSON and write it to a file or writeable object

Attributes

data

The data property is a tuple of the figure’s trace objects

frames

The frames property is a tuple of the figure’s frame objects

layout

The layout property of the figure