Powered by AppSignal & Oban Pro

Add Parameter Values

39_add_parameter_values.livemd

Add Parameter Values

Mix.install([
  {:plotly_ex, "~> 0.3"},
  {:kino, "~> 0.18"}
])

Section

Adding explicit a: and b: parameter arrays to the carpet trace gives each grid point named coordinates. Here a ∈ {4, 4.5, 5, 6} and b ∈ {1, 2, 3}, forming a 4×3 grid.

alias Plotly.{Figure, Carpet}

Figure.new()
|> Figure.add_trace(
  Carpet.new(
    a: [4, 4, 4, 4.5, 4.5, 4.5, 5, 5, 5, 6, 6, 6],
    b: [1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3],
    y: [2, 3.5, 4, 3, 4.5, 5, 5.5, 6.5, 7.5, 8, 8.5, 10]
  )
)
|> Figure.update_layout(title: "Carpet Plot — Parameter Values")
|> Plotly.show()