Makie 2D & 3D plots in WebAssembly.

Pure-Julia Axis and Axis3 compiled to WasmGC + Canvas2D — zero Julia server, zero Three.js.

Drag to orbit · Scroll to zoom
az230
el23
zoom100
View Julia source for this live 3D surfaceAxis3 · WasmGC
using WasmMakie

fig = Figure(size = (880, 480))
ax = Axis3(
    fig[1, 1];
    title = "Interactive 3D Wave Surface",
    xlabel = "x",
    ylabel = "y",
    zlabel = "sinc(r)",
    azimuth = 1.275 * pi,
    elevation = pi / 8,
    perspectiveness = 0.25,
)

xs = collect(range(-6.0, 6.0; length = 25))
ys = collect(range(-6.0, 6.0; length = 25))
zs = [let r = sqrt(x^2 + y^2); r == 0.0 ? 1.0 : sin(r) / r end for x in xs, y in ys]

sf = surface!(ax, xs, ys, zs; colormap = :viridis)
wireframe!(ax, xs, ys, zs; color = (:black, 0.22), linewidth = 0.6)
Colorbar(fig[1, 2], sf; label = "Amplitude")

save("sombrero3d.html", fig)

Interactive 2D figures in WasmGC

Layout, ticks, colormap LUTs, and Canvas2D draw calls recompute live in the browser.

freq3
damping %25
colormap
View Julia source for this live 2D plotHeroPlot.jl
import WasmMakie as WM
using WasmMakie: band!, heatmap!, hlines!, lines!, scatter!

function _select_hero_colormap(idx::Int64)::WM.ColormapSpec
    if idx == Int64(2)
        return WM.to_colormap_spec(:plasma)
    elseif idx == Int64(3)
        return WM.to_colormap_spec(:inferno)
    elseif idx == Int64(4)
        return WM.to_colormap_spec(:coolwarm)
    end
    return WM.to_colormap_spec(:viridis)
end

function _build_hero_figure(freq_i::Int64, damp_pct::Int64, cmap_i::Int64)
    freq = Float64(freq_i)
    damp = Float64(damp_pct) / 100.0
    cmap = _select_hero_colormap(cmap_i)

    fig = WM.Figure(size = (960.0, 380.0))

    ax1 = WM.Axis(
        fig[1, 1];
        title = "Damped Signal & Confidence Band",
        xlabel = "t",
        ylabel = "Response",
    )

    n = Int64(120)
    ts = Float64[]
    ys = Float64[]
    lo = Float64[]
    hi = Float64[]
    i = Int64(0)
    while i < n
        t = Float64(i) / Float64(n - Int64(1)) * 6.0
        env = exp(-damp * t)
        y = env * sin(freq * t)
        err = 0.12 + 0.14 * env
        push!(ts, t)
        push!(ys, y)
        push!(lo, y - err)
        push!(hi, y + err)
        i = i + Int64(1)
    end

    sx = Float64[]
    sy = Float64[]
    ns = Int64(14)
    j = Int64(0)
    while j < ns
        t = 0.25 + Float64(j) / Float64(ns - Int64(1)) * 5.5
        y = exp(-damp * t) * sin(freq * t)
        push!(sx, t)
        push!(sy, y)
        j = j + Int64(1)
    end

    band!(ax1, ts, lo, hi; color = (WM.Cycled(1), 0.22))
    lines!(ax1, ts, ys; linewidth = 2.2, color = WM.Cycled(1), label = "model")
    scatter!(ax1, sx, sy; markersize = 7.0, color = WM.Cycled(2), label = "samples")
    hlines!(ax1, [0.0]; color = (:gray, 0.65), linestyle = :dash)
    WM.axislegend(ax1; position = :rt)

    ax2 = WM.Axis(fig[1, 2]; title = "2D Interference Field", xlabel = "x", ylabel = "y")

    nx = Int64(28)
    ny = Int64(20)
    xh = Float64[]
    ex = Int64(0)
    while ex <= nx
        push!(xh, Float64(ex) / Float64(nx) * 6.283185307179586)
        ex = ex + Int64(1)
    end
    yh = Float64[]
    ey = Int64(0)
    while ey <= ny
        push!(yh, Float64(ey) / Float64(ny) * 3.141592653589793)
        ey = ey + Int64(1)
    end

    vals = Float64[]
    cy = Int64(0)
    while cy < ny
        y = (Float64(cy) + 0.5) / Float64(ny) * 3.141592653589793
        cx = Int64(0)
        while cx < nx
            x = (Float64(cx) + 0.5) / Float64(nx) * 6.283185307179586
            r = sqrt((x - 3.141592653589793)^2 + (y - 1.5707963267948966)^2)
            push!(vals, exp(-damp * 0.45 * r) * sin(freq * 0.5 * x) * cos(freq * 0.5 * y))
            cx = cx + Int64(1)
        end
        cy = cy + Int64(1)
    end

    hm = heatmap!(ax2, xh, yh, vals, nx, ny; colormap = cmap)
    WM.Colorbar(fig[1, 3], hm; label = "Field")

    return fig
end

@island hydrate = :eager function HeroPlot()
    freq, set_freq = create_signal(Int64(3))
    damp_pct, set_damp_pct = create_signal(Int64(25))
    cmap_idx, set_cmap_idx = create_signal(Int64(1))

    create_effect(
        () -> begin
            fig = _build_hero_figure(freq(), damp_pct(), cmap_idx())
            WM.render!(fig, WM.WasmCtx())
        end,
    )

    return Div(
        Canvas(:width => 960, :height => 380),
        Button(:on_click => () -> set_freq(max(Int64(1), freq() - Int64(1))), "-"),
        Span(freq),
        Button(:on_click => () -> set_freq(min(Int64(8), freq() + Int64(1))), "+"),
        Button(:on_click => () -> set_damp_pct(max(Int64(5), damp_pct() - Int64(10))), "-"),
        Span(damp_pct),
        Button(
            :on_click => () -> set_damp_pct(min(Int64(75), damp_pct() + Int64(10))),
            "+",
        ),
        Button(:on_click => () -> set_cmap_idx(Int64(1)), "viridis"),
        Button(:on_click => () -> set_cmap_idx(Int64(2)), "plasma"),
        Button(:on_click => () -> set_cmap_idx(Int64(3)), "inferno"),
        Button(:on_click => () -> set_cmap_idx(Int64(4)), "coolwarm"),
    )
end

One-line swap from CairoMakie

Keep your Makie Figure, Axis, Axis3, recipes, colormaps, and layouts. For full Makie syntax, see docs.makie.org.

CairoMakie.jlDesktop / PNG / PDF
using CairoMakie

fig = Figure(size = (720, 420))
ax = Axis(fig[1, 1]; title = "Damped Response", xlabel = "t", ylabel = "y")
ts = collect(range(0.0, 6.0; length = 120))
ys = exp.(-0.25 .* ts) .* sin.(3.0 .* ts)
err = 0.12 .+ 0.14 .* exp.(-0.25 .* ts)

band!(ax, ts, ys .- err, ys .+ err; color = (Cycled(1), 0.22))
lines!(ax, ts, ys; linewidth = 2.2, color = Cycled(1), label = "model")
hlines!(ax, [0.0]; color = (:gray, 0.65), linestyle = :dash)
axislegend(ax; position = :rt)

save("plot.png", fig)
WasmMakie.jlBrowser Canvas2D / WasmGC
using WasmMakie

fig = Figure(size = (720, 420))
ax = Axis(fig[1, 1]; title = "Damped Response", xlabel = "t", ylabel = "y")
ts = collect(range(0.0, 6.0; length = 120))
ys = exp.(-0.25 .* ts) .* sin.(3.0 .* ts)
err = 0.12 .+ 0.14 .* exp.(-0.25 .* ts)

band!(ax, ts, ys .- err, ys .+ err; color = (Cycled(1), 0.22))
lines!(ax, ts, ys; linewidth = 2.2, color = Cycled(1), label = "model")
hlines!(ax, [0.0]; color = (:gray, 0.65), linestyle = :dash)
axislegend(ax; position = :rt)

save("plot.html", fig)

Two ways to ship a figure

1. Static HTML Replay

Zero Wasm

Call save("plot.html", fig) or html_snippet(fig; hidpi = true) to embed a self-contained Canvas2D replay stream with bundled fonts.

2. Live Compiled WasmGC

Interactive

Compile any plotting function with compile_figure or a Therapy @island using render!(fig, WasmCtx()) to run compute and drawing client-side.

Built for the GroupTherapy stack

Read Stack Guide →

WasmTarget.jl

Compiler

Compiles plotting kernels alongside pure-Julia LinearAlgebra, Random, and StatsBase directly to WasmGC.

Therapy.jl

Web Framework

Reactive @island plots driven by signals and effects, streaming external .wasm modules with lazy hydration.

Snapshot.jl

Notebooks

Exports interactive Pluto notebooks into standalone client-side WasmGC bundles with flicker-free OffscreenCanvas presentation.