Basic Violin Plot in Makie.jl (Julia)

The same plot in 14 other libraries — Python: Altair, Bokeh, lets-plot, Matplotlib, Plotly, plotnine, Pygal, Seaborn; R: ggplot2; JavaScript: Chart.js, D3.js, Apache ECharts, Highcharts, MUI X Charts. Compare all 15 side by side: Basic Violin Plot in Python, R, Julia and JavaScript.

A violin plot combining a box plot with a kernel density estimation on each side, showing the distribution shape of numerical data. The width of the violin at each point represents the frequency of data values at that level. Excellent for comparing distributions across categories while revealing their underlying shape, providing more detail than a traditional box plot.

Basic Violin Plot rendered with Makie.jl

Renders

Julia source (Makie.jl)

# anyplot.ai
# violin-basic: Basic Violin Plot
# Library: makie 0.24.16 | Julia 1.13.4
# Quality: 83/100 | Updated: 2026-11-27

using CairoMakie
using Colors
using DataFrames
using Random

# Theme tokens — Imprint palette
const THEME       = get(ENV, "ANYPLOT_THEME", "light")
const PAGE_BG     = THEME == "light" ? colorant"#FAF8F1" : colorant"#1A1A17"
const INK         = THEME == "light" ? colorant"#1A1A17" : colorant"#F0EFE8"
const INK_SOFT    = THEME == "light" ? colorant"#4A4A44" : colorant"#B8B7B0"

# Imprint palette
const IMPRINT_PALETTE = [
    colorant"#009E73",
    colorant"#C475FD",
    colorant"#4467A3",
    colorant"#BD8233",
    colorant"#AE3030",
    colorant"#2ABCCD",
    colorant"#954477",
    colorant"#99B314",
]

# Columns: set these to your table's column names
const MODE     = "Transport mode"          # role: category
const DURATION = "Commute duration (min)"  # role: value

# Data: replace this block with your own table, for example df = CSV.read("commutes.csv", DataFrame)
Random.seed!(42)
n = 250
modes = ["Walk", "Bike", "Bus", "Car"]
durations = [
    clamp.(randn(n) .* 4.0 .+ 18.0, 4.0, Inf),                                  # walk: narrow
    clamp.(randn(n) .* 7.0 .+ 24.0, 4.0, Inf),                                  # bike: roughly normal
    clamp.(10.0 .+ 55.0 .* rand(n) .^ 2.5, 4.0, Inf),                           # bus: right-skewed
    clamp.(vcat(randn(n ÷ 2) .* 4.0 .+ 16.0, randn(n ÷ 2) .* 8.0 .+ 48.0), 4.0, Inf), # car: bimodal
]
df = DataFrame(
    MODE => repeat(modes; inner = n),
    DURATION => vcat(durations...),
)

# Plot: reads only df and the constants above
categories = unique(df[!, MODE])
x = [findfirst(==(m), categories) for m in df[!, MODE]]
values = df[!, DURATION]

fig = Figure(
    size            = (1600, 900),
    fontsize        = 14,
    backgroundcolor = PAGE_BG,
)

ax = Axis(
    fig[1, 1];
    title              = "violin-basic · julia · makie · anyplot.ai",
    titlesize          = 22,
    titlecolor         = INK,
    xlabel             = MODE,
    ylabel             = DURATION,
    xlabelsize         = 18,
    ylabelsize         = 18,
    xlabelcolor        = INK,
    ylabelcolor        = INK,
    xticklabelsize     = 16,
    yticklabelsize     = 16,
    xticklabelcolor    = INK_SOFT,
    yticklabelcolor    = INK_SOFT,
    xtickcolor         = INK_SOFT,
    ytickcolor         = INK_SOFT,
    backgroundcolor    = PAGE_BG,
    topspinevisible    = false,
    rightspinevisible  = false,
    leftspinecolor     = INK_SOFT,
    bottomspinecolor   = INK_SOFT,
    xgridvisible       = false,
    ygridcolor         = RGBAf(INK.r, INK.g, INK.b, 0.15),
    yminorgridvisible  = false,
    xminorgridvisible  = false,
    xticks             = (eachindex(categories), categories),
)

# One violin per category, one Imprint color each; tails end at the data range
violin!(ax, x, values;
    color       = [RGBAf(c, 0.75) for c in IMPRINT_PALETTE[x]],
    datalimits  = extrema,
    strokewidth = 1.0,
    strokecolor = INK_SOFT,
)

# Quartile box and median line inside each violin
boxplot!(ax, x, values;
    color         = (:white, 0.0),
    strokecolor   = INK,
    strokewidth   = 1.5,
    mediancolor   = INK,
    whiskercolor  = INK,
    width         = 0.12,
    whiskerwidth  = 0.5,
    show_outliers = false,
)

# Save
save("plot-$(THEME).png", fig; px_per_unit = 2)

Retrieve this implementation

Runnable source as JSON, for any HTTP client: https://api.anyplot.ai/specs/violin-basic/makie/code. Any spec id and library id listed in llms-full.txt fit the same URL shape; every URL below is complete and callable.

{
  "spec_id": "violin-basic",
  "language": "julia",
  "library": "makie",
  "page": "https://anyplot.ai/violin-basic/julia/makie",
  "hub": "https://anyplot.ai/violin-basic",
  "code_json": "https://api.anyplot.ai/specs/violin-basic/makie/code",
  "spec_json": "https://api.anyplot.ai/specs/violin-basic",
  "render_light_png": "https://storage.googleapis.com/anyplot-images/plots/violin-basic/julia/makie/plot-light.png",
  "render_dark_png": "https://storage.googleapis.com/anyplot-images/plots/violin-basic/julia/makie/plot-dark.png",
  "quality_score": 83.0,
  "license": "MIT",
  "guide": "https://anyplot.ai/llms.txt"
}

Part of Basic Violin Plot on anyplot.ai.

Other implementations