Tucan - a plotting library on top of VegaLite

Tucan is an Elixir plotting library built on top of VegaLite designed to simplify the creation of interactive and visually stunning plots. With Tucan you can effortlessly generate a wide range of plots, from simple bar charts to complex composite plots, all while enjoying the power and flexibility of a clean composable functional API. Version 0.1.1 was just released :tada:

You can find the docs here.

Sample usage:

scatter =
  Tucan.scatter(:iris, "petal_width", "petal_length", tooltip: true)
  |> Tucan.color_by("species")
  |> Tucan.shape_by("species")

lines = Tucan.lineplot(:stocks, "date", "price", color_by: "symbol", x: [type: :temporal])

area =
  Tucan.area(:stocks, "date", "price", color_by: "symbol", mode: :normalize, x: [type: :temporal])

density = Tucan.density(:penguins, "Body Mass (g)", color_by: "Species", fill_opacity: 0.2)

strip =
  Tucan.stripplot(:tips, "total_bill", group: "day", style: :jitter)
  |> Tucan.color_by("sex")

boxplot = Tucan.boxplot(:penguins, "Body Mass (g)", color_by: "Species")
histogram = Tucan.histogram(:cars, "Horsepower", color_by: "Origin", fill_opacity: 0.5)

pie = Tucan.pie(:barley, "yield", "site", aggregate: :sum, tooltip: true)

donut = Tucan.donut(:barley, "yield", "site", aggregate: :sum, tooltip: true)

heatmap =
  Tucan.density_heatmap(:penguins, "Beak Length (mm)", "Beak Depth (mm)", fill_opacity: 1.0)

  Tucan.hconcat([scatter, lines, area]),
  Tucan.hconcat([density, Tucan.vconcat([strip, boxplot]), histogram]),
  Tucan.hconcat([pie, donut, heatmap])

will generate the following:

Credits go to @jonatanklosko for the awesome VegaLite bindings.


Hey this is looks great!

I’ve been playing with VegaLite recently. I have a Matplotlib background and I think because of that I found the new API a little confusing. I’ll give this a try!


Hey @billylanchantin that was the main reason i implemented it. I have also a seaborn/matplotlib background and the learning curve of VegaLite was steep.


@pnezis this is amazing and charts in the docs are absolute fire!! :cat2: :fire:


Amazing! :fire:

1 Like

Very cool! Any plans for live/dynamically updated charts? It’s the part of VegaLite that made me struggle the most.

1 Like

@jonatanklosko thanks!

The charts are auto-generated from plain markdown code blocks. A custom markdown processor is used that compiles the block, formats it and renders both the original code block and the vega lite spec.

The underlying package originated from a discussion with @josevalim in the ex_doc repo some time ago.


Hi! dynamically updated charts as well as a high level API for interactive charts is in the plans for future releases.


@pnezis would you also support heatmaps? My understanding is that they are similar to your current density heatmap, except there is no binning on X and no aggregate on Y. :slight_smile: (X may also need to be nominal).

@josevalim correct heatmaps are very similar to denisty heatmaps, but for categorical variables on both axes (ordinal or nominal in vegalite terminology) instead of numerical.

I guess I missed it, will definitely add it.


@josevalim heatmap/5 added :slight_smile: Will release a new version later this week


amazing work! :rocket:

1 Like

New version released today: v0.2.0, with many new features:

  • heatmap, punchcard and jointplot plots
  • vruler and hruler for adding vertical/horizontal rulers on any plot
  • Helper modules for configuring the Legend and the Scale
  • Docs improvements, added a livebook guide

You can find the full CHANGELOG here

Any feedback welcome


The new (and old) plots are great!