Annotated Parallel Coordinates Plot
Mix.install([
{:plotly_ex, "~> 0.3"},
{:kino, "~> 0.18"}
])
Section
constraintrange: [low, high] highlights lines that fall within a range on a
given dimension — all others are dimmed. Users can drag to adjust this range
interactively. Setting it in the data pre-selects a subset on load.
alias Plotly.{Figure, Parcoords}
species = [0, 0, 0, 0, 0, 1, 1, 2]
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],
constraintrange: [5.0, 5.5]},
%{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]}
],
line: %{color: species, colorscale: "Viridis", showscale: true}
)
)
|> Figure.update_layout(
title: "Parallel Coordinates — constraintrange highlights Sepal Length 5.0–5.5"
)
|> Plotly.show()