Intermediate

Visualization

Create publication-quality plots and interactive visualizations with Plots.jl and Makie.jl - Julia's two major plotting ecosystems.

Plots.jl - The Universal Interface

Plots.jl provides a unified API that works with multiple backends (GR, Plotly, PyPlot). It is the most popular plotting package in Julia.

Julia
using Plots

# Line plot
x = 0:0.1:2pi
plot(x, sin.(x), label="sin(x)", lw=2)
plot!(x, cos.(x), label="cos(x)", lw=2)
title!("Trigonometric Functions")
xlabel!("x")
ylabel!("y")

# Scatter plot
scatter(rand(50), rand(50),
    markersize=8, alpha=0.6,
    xlabel="X", ylabel="Y",
    title="Random Scatter")

# Save to file
savefig("my_plot.png")
💡
The ! convention: In Julia, functions ending with ! modify their arguments in place. In Plots.jl, plot! adds to the current plot rather than creating a new one.

Common Plot Types

Julia
# Bar chart
bar(["A", "B", "C", "D"], [23, 45, 12, 67], legend=false)

# Histogram
histogram(randn(1000), bins=30, alpha=0.7, label="Normal")

# Heatmap
heatmap(rand(10, 10), color=:viridis, title="Heatmap")

# Subplots
p1 = plot(rand(10), title="Plot 1")
p2 = scatter(rand(10), title="Plot 2")
p3 = bar(rand(5), title="Plot 3")
p4 = histogram(randn(100), title="Plot 4")
plot(p1, p2, p3, p4, layout=(2, 2), size=(800, 600))

Makie.jl - GPU-Powered Visualization

Makie.jl is Julia's next-generation plotting library with GPU acceleration, interactivity, and beautiful defaults.

Julia
using CairoMakie  # For static plots (PNG, PDF, SVG)
# using GLMakie    # For interactive/3D plots

# Basic line plot
fig = Figure(size=(800, 400))
ax = Axis(fig[1, 1], title="Sine Wave", xlabel="x", ylabel="y")
x = 0:0.01:4pi
lines!(ax, x, sin.(x), color=:blue, linewidth=2)
lines!(ax, x, cos.(x), color=:red, linewidth=2)
save("makie_plot.png", fig)

# Makie with DataFrames
using DataFrames
df = DataFrame(x=randn(200), y=randn(200), group=rand(["A","B"], 200))
fig, ax, plt = scatter(df.x, df.y, color=df.group .== "A",
    colormap=[:blue, :orange], markersize=10)

Plots.jl vs Makie.jl

FeaturePlots.jlMakie.jl
Ease of useSimple, concise APIMore verbose but flexible
PerformanceGoodGPU-accelerated, excellent
InteractivityVia Plotly backendNative with GLMakie
3D plotsBasicExcellent
Publication qualityGoodExcellent
Best forQuick explorationPublication & dashboards
Recommendation: Start with Plots.jl for quick data exploration. Switch to CairoMakie for publication-quality figures and GLMakie for interactive or 3D visualizations.

Ready to Go Deeper?

Live instructor-led courses from our partners. Affiliate disclosure.