Plotly_ex - Interactive Plotly.js charts for Elixir - works in LiveBook via Kino and in Phoenix LiveView

plotly_ex is an Elixir library providing bindings for Plotly. This library was heavily inspired by VegaLite, which I do love. However, over the last year or so, I found myself producing various data sets via Elixir apps, only to have to export them out and presented via throwaway R::shiny apps that relied on the R plotly library to produce interactive plots that I used in many of my presentations. Although I did find some previous attempts of the community at implementing such bindings for Elixir, for example s417-lama/plotly_ex, this project appears to have been abandoned.

Like VegaLiteas well as the python version of the Plotly bindings, plotly_ex provides both a concise “express” API for rapid chart creation as well as a “fluent builder” API for fine-grained control with LiveBook and Phoenix LiveView integration. A Kino SmartCell is also available for simple plot types in LiveBook.

I’ve released on github

Any and all suggestions welcome.


LiveBook example code:

Mix.install([
  {:plotly_ex, "~> 0.1"},
  {:kino, "~> 0.14"},
  {:explorer, "~> 0.11"}
])


data = [
  %{"month" => "Jan", "sales" => 42},
  %{"month" => "Feb", "sales" => 55},
  %{"month" => "Mar", "sales" => 38}
]
Plotly.bar(data, x: "month", y: "sales", title: "Monthly Sales")
|> Plotly.show()


# or using an Explorer DataFrame:
df = Explorer.DataFrame.new(x: [1, 2, 3], y: [10, 20, 15])
Plotly.scatter(df, x: "x", y: "y", title: "From DataFrame")
|> Plotly.show()
4 Likes