Adding Dimensions to a Parallel Coordinates Plot
Mix.install([
{:plotly_ex, "~> 0.3"},
{:kino, "~> 0.18"}
])
Section
Parcoords.new(dimensions: [...]) draws one vertical axis per dimension.
Each dimension map needs label: (axis title) and values: (one value per observation).
Lines connect each observation's values across all axes.
alias Plotly.{Figure, Parcoords}
Figure.new()
|> Figure.add_trace(
Parcoords.new(
dimensions: [
%{label: "Sepal Length", values: [5.1, 4.9, 4.7, 5.0, 5.4, 6.3, 5.8, 7.1]},
%{label: "Sepal Width", values: [3.5, 3.0, 3.2, 3.6, 3.9, 3.3, 2.7, 3.0]},
%{label: "Petal Length", values: [1.4, 1.4, 1.3, 1.4, 1.7, 4.7, 5.1, 5.9]},
%{label: "Petal Width", values: [0.2, 0.2, 0.2, 0.2, 0.4, 1.6, 1.9, 2.1]}
]
)
)
|> Figure.update_layout(title: "Parallel Coordinates — Adding Dimensions")
|> Plotly.show()