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.
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")
! 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
# 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.
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
| Feature | Plots.jl | Makie.jl |
|---|---|---|
| Ease of use | Simple, concise API | More verbose but flexible |
| Performance | Good | GPU-accelerated, excellent |
| Interactivity | Via Plotly backend | Native with GLMakie |
| 3D plots | Basic | Excellent |
| Publication quality | Good | Excellent |
| Best for | Quick exploration | Publication & dashboards |
Ready to Go Deeper?
Live instructor-led courses from our partners. Affiliate disclosure.
AI & ML Courses - 30% Off
Live instructor-led AI, machine learning, data science, and cloud courses for working professionals. Use code Limited30 at checkout.
EdurekaDataCamp - AI & Data Science
Hands-on Python, machine learning, and AI courses with interactive exercises and real projects.
DataCampedX - Top AI Courses
University-level AI courses from MIT, Harvard, Stanford. Earn certificates that employers recognize.
edX