Powered by AppSignal & Oban Pro

Simple Contour Plot

01_simple_contour_plot.livemd

Simple Contour Plot

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

Section

Contour.new(z: [[...]]) takes a 2D list (list of rows) of numeric values. Plotly automatically picks the contour levels, colour scale, and axis ranges. Each inner list is one row of the z matrix.

alias Plotly.{Figure, Contour}

z = for i <- 0..19 do
  for j <- 0..19 do
    :math.sin(i * :math.pi() / 10) * :math.cos(j * :math.pi() / 10)
  end
end

Figure.new()
|> Figure.add_trace(Contour.new(z: z))
|> Figure.update_layout(title: "Simple Contour Plot")
|> Plotly.show()