Boxes and violins

Introduction to Data Visualization with Julia

Gustavo Vieira Suñe

Data Analyst

Histograms with many categories

A stacked histogram displaying the distribution of onion and wheat prices.

A stacked histogram displaying the distribution of onion, potato, tomato and wheat prices.

  • Hard to compare many categories
Introduction to Data Visualization with Julia

Box plots

A box plot displaying the distribution of onion, potato, tomato and wheat prices.

Introduction to Data Visualization with Julia

Boxes of product

using StatsPlots

boxplot( # Categories in x-axis kerala[:, :Commodity], # Values in y-axis kerala[:, :Price],
color=:darkorange, label=false, ) ylabel!("Price (Rupees)")

A box plot displaying the distribution of onion, potato, tomato and wheat prices.

Introduction to Data Visualization with Julia

Hiding outliers

using StatsPlots

boxplot(
    # Categories in x-axis
    kerala[:, "Commodity"],
    # Values in y-axis
    kerala[:, :Price],
    color=:darkorange,
    label=false,

# Hide outliers outliers=false,
) ylabel!("Price (Rupees)")

A box plot displaying the distribution of onion, potato, tomato and wheat prices, with outliers omitted.

Introduction to Data Visualization with Julia

Violin plots

A violin plot displaying the distribution of onion, potato, tomato and wheat prices.

Introduction to Data Visualization with Julia

Distributions with violin plot

# Create violin plot
violin(
    # Categories in x-axis
    kerala[:, :Commodity],
    # Values in y-axis
    kerala[:, :Price],

# Remove lines linewidth=0,
color=:darkorange, label=false, ) ylabel!("Price (Rupees)")

A violin plot displaying the distribution of onion, potato, tomato and wheat prices.

Introduction to Data Visualization with Julia

Boxes or violins?

  • Box plots
    • Central tendency, spread & skewness
    • Emphasize outliers

A box plot displaying the distribution of onion, potato, tomato and wheat prices.

  • Violin plots
    • Details of distribution
    • Shape is relevant (e.g., multimodal)

A violin plot displaying the distribution of onion, potato, tomato and wheat prices.

Introduction to Data Visualization with Julia

Let's practice!

Introduction to Data Visualization with Julia

Preparing Video For Download...