Trace-based charts
Build a chart from low-level graph-object traces.
Plotly · Class
go.Figure constructs a Plotly graph-object figure from optional traces and layout settings. Start empty for incremental construction or provide data and layout immediately.
Constructs a Plotly figure from optional data and layout inputs. The data can contain graph-object traces, while the layout configures chart-wide properties; an empty figure can also be created and populated later with methods such as add_trace and update_layout.
plotly.graph_objects.Figure(data=None, layout=None, frames=None, skip_invalid=False, **kwargs)| Name | Type | Description |
|---|---|---|
data | array-like | Plotly trace or traces used as the figure's plotted data. |
layout | plotly.graph_objects.Layout | Chart-wide configuration, including axes and presentation properties. |
A plotly.graph_objects.Figure instance.
import plotly.graph_objects as go
fig = go.Figure(
data=[go.Scatter(x=[1, 2, 3], y=[1, 4, 9], mode="lines+markers")],
layout=go.Layout(title="Squares")
)
fig.show()Creates a figure from a scatter trace and an explicit layout, then displays the interactive chart.
Build a chart from low-level graph-object traces.
Create a chart progressively before displaying it.
Apply shared axes, titles, and presentation settings.
go.Figure is the graph-object constructor for a Plotly chart. It accepts trace data and an optional layout, and the resulting figure can be displayed with show().
Follow-up: How would you build a chart incrementally? Start with go.Figure(), then add traces with add_trace() and configure chart-wide properties with update_layout().
Pass one trace or a list of traces through data, and use layout for chart-level configuration. A figure may also be initialized empty and filled later.
Follow-up: How can subplot figures be created? Use plotly.subplots.make_subplots(), or configure subplots on an existing figure with set_subplots().
The constructor belongs to plotly.graph_objects and is commonly used with graph-object trace classes such as go.Scatter. It produces an interactive figure object that supports methods for adding and updating chart content.
Follow-up: What is a practical distinction between a trace and a layout? A trace represents plotted data, while layout controls shared presentation and axes settings.
plotly.graph_objects.Scatterplotly.graph_objects.LayoutFigure.add_traceFigure.update_layoutplotly.subplots.make_subplots