Ternary Line Plot
Ternary line plots are a data visualization technique that represents data in a triangular coordinate system. They display data as connected line segments within the triangular space, making them useful for visualizing relationships, trends, and compositional data that sum to a constant total. Ternary line plots are particularly valuable when dealing with data involving three mutually exclusive components or proportions.
Ternary line plots are appropriate when the data contain three interrelated mutually exclusive categories whose relationships can be quantified with a continuous variable. Further, ternary line plots are preferable to ternary scatter plots when the explanatory variables are ordered.
What are ternary line plots useful for?
- Compositional data representation: Ternary line plots are suitable for representing compositional data where the total proportion remains constant, allowing for the visualization of how components change relative to one another.
- Multivariate data analysis: They are useful in multivariate data analysis to visualize relationships and trends among three variables or components that are interrelated.
- Optimization studies: They can be applied in optimization studies to understand how adjustments in the proportions of three components impact the overall composition, aiding in informed decision-making.
Examples
A basic ternary line plot
Visualize a ternary dataset by passing column names to each of the a
, b
, and c
arguments.
import deephaven.plot.express as dx
election = dx.data.election()
ternary_line_plot = dx.line_ternary(election, a="Joly", b="Coderre", c="Bergeron")
API Reference
Returns a ternary line chart
Returns: DeephavenFigure
A DeephavenFigure that contains the ternary line chart
Parameters | Type | Default | Description |
---|---|---|---|
table | PartitionedTable | Table | DataFrame | A table to pull data from. | |
a | str | None | None | A column that contains a-axis values. |
b | str | None | None | A column that contains b-axis values. |
c | str | None | None | A column that contains c-axis values. |
by | str | None | list[str] | None | A column or list of columns that contain values to plot the figure traces by. All values or combination of values map to a unique design. The variable by_vars specifies which design elements are used. This is overriden if any specialized design variables such as color are specified |
by_vars | str | list[str] | 'color' | A string or list of string that contain design elements to plot by. Can contain size, line_dash, width, color, and symbol. If associated maps or sequences are specified, they are used to map by column values to designs. Otherwise, default values are used. |
size | str | None | None | A column or list of columns that contain size values. If only one column is passed, and it contains numeric values, the value is used as a size. Otherwise, the value is used for a plot by on size. See size_map for additional behaviors. |
line_dash | str | list[str] | None | None | A column or list of columns that contain line_dash values. The value is used for a plot by on line_dash. See line_dash_map for additional behaviors. |
width | str | list[str] | None | None | A column or list of columns that contain width values. The value is used for a plot by on width. See width_map for additional behaviors. |
color | str | list[str] | None | None | A column or list of columns that contain color values. The value is used for a plot by on color. See color_discrete_map for additional behaviors. |
symbol | str | list[str] | None | None | A column or list of columns that contain symbol values. The value is used for a plot by on symbol. See color_discrete_map for additional behaviors. |
text | str | None | None | A column that contains text annotations. |
hover_name | str | None | None | A column that contains names to bold in the hover tooltip. |
labels | dict[str, str] | None | None | A dictionary of labels mapping columns to new labels. |
color_discrete_sequence | list[str] | None | None | A list of colors to sequentially apply to the series. The colors loop, so if there are more series than colors, colors will be reused. |
color_discrete_map | dict[str | tuple[str], str] | None | None | If dict, the keys should be strings of the column values (or a tuple of combinations of column values) which map to colors. |
line_dash_sequence | list[str] | None | None | A list of line dashes to sequentially apply to the series. The dashes loop, so if there are more series than dashes, dashes will be reused. |
line_dash_map | dict[str | tuple[str], str] | None | None | If dict, the keys should be strings of the column values (or a tuple of combinations of column values) which map to line_dash. |
symbol_sequence | list[str] | None | None | A list of symbols to sequentially apply to the markers in the series. The symbols loop, so if there are more series than symbols, symbols will be reused. |
symbol_map | str | tuple[str, dict[str | tuple[str], dict[str | tuple[str], str]]] | dict[str | tuple[str], str] | None | None | If dict, the keys should be strings of the column values (or a tuple of combinations of column values) which map to symbols. If "identity", the values are taken as literal symbols. If "by" or ("by", dict) where dict is as described above, the symbols are forced to by |
size_sequence | list[int] | None | None | A list of sizes to sequentially apply to the markers in the series. The sizes loop, so if there are more series than symbols, sizes will be reused. |
size_map | str | tuple[str, dict[str | tuple[str], dict[str | tuple[str], str]]] | dict[str | tuple[str], str] | None | None | If dict, the keys should be strings of the column values (or a tuple of combinations of column values) which map to sizes. If "identity", the values are taken as literal sizes. If "by" or ("by", dict) where dict is as described above, the sizes are forced to by |
width_sequence | list[int] | None | None | A list of widths to sequentially apply to the series. The widths loop, so if there are more series than widths, widths will be reused. |
width_map | dict[str | tuple[str], str] | None | None | If dict, the keys should be strings of the column values (or a tuple of combinations of column values) which map to width. |
markers | bool | False | True to draw markers on the line, False to not. Default False |
line_shape | str | 'linear' | The line shape for all lines created. One of 'linear', 'spline'. |
title | str | None | None | The title of the chart |
template | str | None | None | The template for the chart. |
unsafe_update_figure | Callable | <function default_callback> | An update function that takes a plotly figure as an argument and optionally returns a plotly figure. If a figure is not returned, the plotly figure passed will be assumed to be the return value. Used to add any custom changes to the underlying plotly figure. Note that the existing data traces should not be removed. This may lead to unexpected behavior if traces are modified in a way that break data mappings. |