Point plots
Show individual observations as points in an interactive chart.
Plotly · Class
go.Scatter is Plotly’s generic graph_objects trace for two-dimensional scatter visualizations. Its mode controls whether data appears as markers, lines, or both.
go.Scatter creates a generic two-dimensional scatter trace for plotly.graph_objects. Set mode to choose points, lines, or both, then place the trace in a Figure and display the result.
go.Scatter(x=None, y=None, mode=None, **kwargs)import plotly.graph_objects as go
fig = go.Figure(go.Scatter(
x=[1, 2, 3],
y=[2, 1, 4],
mode="markers+lines",
name="Measurements"
))
fig.show()Creates an interactive Plotly figure containing one scatter trace with both points and connecting lines.
Show individual observations as points in an interactive chart.
Connect ordered measurements to reveal a trend.
Combine observations and their connecting path in one trace.
Use a lower-level trace when Plotly Express is not a suitable starting point.
go.Scatter is a generic graph_objects class for two-dimensional scatter traces. It can represent either points or lines, and the mode value determines which rendering is used.
Follow-up: How would you render both representations? Set mode to the combined markers-and-lines option, such as "markers+lines".
Create the trace with x and y data, pass it to go.Figure, and call show on the figure. The documented pattern is a Figure containing a go.Scatter trace.
Follow-up: How can the trace be added after figure construction? Use the Figure add-trace method with a go.Scatter instance.
Plotly Express provides separate scatter and line functions, while go.Scatter is the lower-level generic option that supports both kinds of plot through mode.
Follow-up: When should you consider the graph_objects class? Use it when Plotly Express is not a suitable starting point or when direct trace control is needed.
plotly.graph_objects.Figureplotly.express.scatterplotly.express.linego.Scatter3d