View Source Tucan.Themes (tucan v0.4.1)

Helper functions for Tucan theme.

You can apply any of the supported themes through the Tucan.set_theme/2 helper:

Tucan.scatter(:iris, "petal_width", "petal_length")
|> Tucan.color_by("species")
|> Tucan.shape_by("species")
|> Tucan.set_theme(:latimes)

Themes and livebook

If you are using Tucan with livebook notice that kino_vega_lite applies by default a theme that may override Tucan theme settings. You can disable the default theme through Kino.VegaLite.configure/1:

# disable default livebook theme
Kino.VegaLite.configure(theme: nil)

Tucan.scatter(:iris, "petal_width", "petal_length")
|> Tucan.color_by("species")
|> Tucan.shape_by("species")
|> Tucan.set_theme(:dark)

About themes

A Tucan theme is nothing more than a keyword list with a VegaLite configuration object with some styles applied and some metadata. Every theme must have the following format:

[
   theme: [],          # the actual theme configuration
   name: :name,        # an atom with a unique name
   doc: "description", # a description of the theme,
   source: "url"       # a url to the source of the theme if any for attribution
]

Default themes

Tucan comes pre-packed with a set of themes, borrowed by the Vega Themes project. You can set a theme to a plot by calling the Tucan.set_theme/2 function. If no theme set the default vega-lite theme is used. In all examples below the following example plot is used:

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_by: "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)")

Tucan.vconcat([
  Tucan.hconcat([scatter, lines, area]),
  Tucan.hconcat([density, Tucan.vconcat([strip, boxplot]), histogram]),
  Tucan.hconcat([pie, donut, heatmap])
])
|> VegaLite.config(legend: [disable: true])
|> VegaLite.resolve(:scale, color: :independent)

The following themes are currently supported:

:dark

A dark theme [source]

Example:

:excel

Chart theme modeled after excel [source]

Example:

:five_thirty_eight

Chart theme modeled after FiveThirtyEight [source]

Example:

:ggplot2

Chart theme modeled after ggplot2 [source]

Example:

:google_charts

Chart theme modeled after Google Charts [source]

Example:

:latimes

Chart theme modeled after the Los Angeles Times [source]

Example:

:power_bi

Chart theme modeled after Power BI [source]

Example:

:quartz

Chart theme modeled after Quartz [source]

Example:

:urban_institute

Chart theme modeled after Urban Institute [source]

Example:

:vox

Chart theme modeled after Vox [source]

Example:

Summary

Functions

Returns the configuration object for the given theme.

Functions

@spec theme(name :: atom()) :: keyword()

Returns the configuration object for the given theme.

An exception will be raised if the theme name is invalid.