Visualization
StatsPlots.jl adds @df df scatter(:x, :y, group=:g), boxplots, violin, corrplot.
37.1 Plots.jl (meta-package with many backends)
StatsPlots.jl adds @df df scatter(:x, :y, group=:g), boxplots, violin, corrplot.
using Plots
x = range(0, 2π, length=100)
plot(x, sin.(x), label="sin", lw=2, title="Trig", xlabel="x", ylabel="y")
plot!(x, cos.(x), label="cos", ls=:dash) # add to the current plot
scatter(rand(50), rand(50), ms=4, color=:red)
histogram(randn(1000), bins=30)
bar(["a", "b", "c"], [3, 5, 2])
heatmap(rand(10, 10)); contour(x, x, (a, b) -> sin(a) * cos(b))
surface(x, x, (a, b) -> sin(a) + cos(b))
plot(p1, p2, layout=(1, 2), size=(900, 400))
savefig("plot.png") # also .pdf, .svg
anim = @animate for i in 1:50; plot(x, sin.(x .+ i / 10)); end; gif(anim, "wave.gif")
gr(); plotlyjs(); pythonplot() # switch backends37.2 Makie.jl (high-performance, publication & interactive)
AlgebraOfGraphics.jl offers a grammar-of-graphics layer on Makie (ggplot2-like). Others: VegaLite.jl, Gadfly.jl, PlotlyJS.jl, UnicodePlots.jl (plots in the terminal), GraphMakie.jl, GeoMakie.jl, Luxor.jl (drawing), Javis.jl (animations).
using CairoMakie # GLMakie for interactive 3-D, WGLMakie for the browser
fig = Figure(size=(800, 400))
ax = Axis(fig[1, 1], title="Makie", xlabel="x", ylabel="y")
lines!(ax, x, sin.(x), label="sin")
scatter!(ax, x[1:10:end], cos.(x[1:10:end]), color=:red, label="cos")
axislegend(ax)
ax2 = Axis(fig[1, 2]); hist!(ax2, randn(1000))
save("makie.png", fig)
fig