Customizing with themes

Introduction to Data Visualization with Julia

Gustavo Vieira Suñe

Data Analyst

Plots.jl themes

  • Easy customization
using Plots

# Set theme
theme(thm::Symbol; kwargs...)
  • Many theme (thm) choices: :default, :dark, :ggplot2, :juno, ...
  • kwargs: set default attributes

E.g., theme(:juno, linecolor=:red, linewidth=5)

Introduction to Data Visualization with Julia

Previewing themes

showtheme(:ggplot2)

A figure containing many different plots created using the ggplot2 theme.

showtheme(:juno)

A figure containing many different plots created using the juno theme.

Introduction to Data Visualization with Julia

Favorite music genres

  • Music effects on mental health dataset.
using DataFrames, CSV, Plots

# Load dataset
streaming = DataFrame(CSV.File("streaming.csv"))

# Group by genre grouped = groupby(streaming, "Fav genre") # Count genres counts = combine(grouped, nrow => :count)
  • Visualize with bar chart!
Introduction to Data Visualization with Julia

Default-themed bar chart

# Bar chart with :default
bar(
    counts[!, "Fav genre"],
    counts.count,

title="Favorite Music Genres" ylabel="Frequency", label=false, )

A bar chart displaying the counts of favorite genres created using the default theme.

Introduction to Data Visualization with Julia

Try a different theme

# Set the theme
theme(:juno)

# Bar chart with :juno bar( counts[!, "Fav genre"], counts.count, label=false, ylabel="Frequency", title="Favorite Music Genres" )

A bar chart displaying the counts of favorite genres created using the juno theme.

Introduction to Data Visualization with Julia

Make it pop!

theme(
    :juno,

# Default line color and width linecolor=:red, linewidth=5,
# Hide the axis lines framestyle=:grid )
bar( counts[!, "Fav genre"], counts.count, label=false, ylabel="Frequency", title="Favorite Music Genres" )

A bar chart displaying the counts of favorite genres created using the default theme, with a thick red line around the bars.

  • Save to file: savefig("genres.png")
Introduction to Data Visualization with Julia

Let's practice!

Introduction to Data Visualization with Julia

Preparing Video For Download...