Simple Subplot
Mix.install([
{:plotly_ex, "~> 0.3"},
{:kino, "~> 0.18"}
])
Section
layout.grid creates a subplot grid. Set rows: and columns: with pattern: "independent"
to give each cell its own axes. Traces reference their cell via xaxis: "x2" etc.
The first cell always uses xaxis/yaxis (no number suffix).
alias Plotly.{Figure, Scatter}
Figure.new()
|> Figure.add_trace(Scatter.new(x: [1, 2, 3], y: [4, 5, 6], name: "Trace 1"))
|> Figure.add_trace(Scatter.new(x: [2, 3, 4], y: [5, 6, 7], xaxis: "x2", yaxis: "y2", name: "Trace 2"))
|> Figure.update_layout(
title: "Simple Subplot",
grid: %{rows: 1, columns: 2, pattern: "independent"}
)
|> Plotly.show()