Composition trajectories
Plot compositional measurements whose three components define a ternary position over ordered observations.
Plotly · Function
Creates an interactive ternary line plot from tabular data. Rows become ternary points, while coordinate, grouping, color, and other Plotly Express arguments control the generated figure.
px.line_ternary creates a complete interactive ternary line figure from tabular data. Each row contributes a point positioned by the a, b, and c values; optional grouping and styling arguments determine which points connect and how the resulting traces appear.
plotly.express.line_ternary(data_frame=None, a=None, b=None, c=None, color=None, line_dash=None, hover_name=None, hover_data=None, custom_data=None, text=None, symbol=None, animation_frame=None, animation_group=None, category_orders=None, labels=None, color_discrete_sequence=None, color_discrete_map=None, line_dash_sequence=None, line_dash_map=None, symbol_sequence=None, symbol_map=None, markers=None, log_a=False, log_b=False, log_c=False, range_a=None, range_b=None, range_c=None, title=None, template=None, width=None, height=None)| Name | Type | Description |
|---|---|---|
data_frame | DataFrame or array-like | Data frame containing the columns used by the chart and its encodings. |
a | str or array-like | Column or array specifying the first ternary coordinate. |
b | str or array-like | Column or array specifying the second ternary coordinate. |
c | str or array-like | Column or array specifying the third ternary coordinate. |
color, line_group, and other keyword arguments | optional | Optional grouping/color encoding and additional Plotly Express styling arguments. |
A plotly.graph_objects.Figure containing the generated interactive ternary line chart.
import plotly.express as px
df = px.data.iris()
fig = px.line_ternary(
df,
a="sepal_width",
b="sepal_length",
c="petal_length",
color="species",
line_group="species",
markers=True,
)
fig.show()Creates an interactive ternary line chart from the Iris data, using three columns as ternary coordinates and grouping/coloring lines by species.
Plot compositional measurements whose three components define a ternary position over ordered observations.
Compare multiple entities by assigning a grouping column and optionally a color encoding.
Build exploratory interactive charts directly from a pandas data frame.
px.line_ternary is Plotly Express’s high-level constructor for ternary line plots. It returns a complete interactive figure rather than only a trace.
Follow-up: How would you create a ternary line without Plotly Express? Use a graph_objects Scatterternary trace and assign its a, b, and c coordinates.
The a, b, and c arguments identify the three data columns used for ternary coordinates. The function consumes these columns for every row in the supplied data frame.
Follow-up: What should be checked when coordinates appear incorrect? Verify that the selected columns contain the intended numeric components and that the ternary layout’s normalization assumptions match the data.
The function is designed for a data-frame-oriented workflow: pass the data frame first, then map columns and optional visual encodings such as color or line grouping. The result can be displayed with fig.show().
Follow-up: How can the chart be customized after construction? Modify the returned Figure with Plotly Figure methods, including layout and trace updates.
plotly.express.scatter_ternaryplotly.graph_objects.Scatterternaryplotly.express.line