Unified Hover Mode
Mix.install([
{:plotly_ex, "~> 0.3"},
{:kino, "~> 0.18"}
])
Section
layout.hovermode: "x unified" displays a single hover box for all traces
at the same x value, instead of per-trace tooltips. Use "y unified" for
horizontal comparisons.
alias Plotly.{Figure, Scatter}
x = Enum.to_list(1..5)
Figure.new()
|> Figure.add_trace(Scatter.new(x: x, y: [1, 3, 2, 4, 3], name: "Alpha", mode: "lines"))
|> Figure.add_trace(Scatter.new(x: x, y: [2, 1, 4, 2, 5], name: "Beta", mode: "lines"))
|> Figure.add_trace(Scatter.new(x: x, y: [3, 2, 1, 3, 2], name: "Gamma", mode: "lines"))
|> Figure.update_layout(
title: "Unified Hover Mode",
hovermode: "x unified"
)
|> Plotly.show()