Powered by AppSignal & Oban Pro

Horizontal Histogram

19_horizontal_histogram.livemd

Horizontal Histogram

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

Section

Pass data as y: instead of x: to produce a horizontal histogram. The x-axis becomes the count axis; y-axis shows the bin ranges.

alias Plotly.{Figure, Histogram}

:rand.seed(:exsss, {1, 2, 3})

y = for _ <- 1..500 do
  (for _ <- 1..12, do: :rand.uniform()) |> Enum.sum() |> Kernel.-(6.0)
end

Figure.new()
|> Figure.add_trace(Histogram.new(y: y))
|> Figure.update_layout(title: "Horizontal Histogram")
|> Plotly.show()