5 Data Vis with Plots.jl

Data visualization is a vital part of almost any data analysis process. Here, in this chapter, we will consider several packages that can be used in Julia, namely Plots.jl, StatsPlots.jl, and Makie.jl

Plots is ….

The default backend is GR.

using Plots, LaTeXStrings
function test_plots_layout()
    x = LinRange(0,2π,50)
    plt1 = Plots.plot(x, sin.(x), st = :scatter, label = "sin(x)",
        m = (3, :black, Plots.stroke(0)), leg =:bottomleft,
        fg_legend = :black, bg_legend = nothing)
    plt2 = Plots.plot(x, sin.(x), c = :black, m=(3,:d,:black,Plots.stroke(0)),
        label = "sin(x)", leg =:bottomleft, fg_legend = :black,
        bg_legend = nothing)
    plt3 = Plots.plot(x, [sin.(x), cos.(x)], c = :black, leg =:topright,
        m = (3, [:d :o], [:black :orangered], Plots.stroke(0)),
        label = ["sin(x)" "cos(x)"], fg_legend = nothing,
        bg_legend = :white, xlab =L"x")
    plt4 = Plots.plot(x, [sin.(x), cos.(x), -sin.(x), -cos.(x)], lw = 1.5,
        c = [:viridis :plasma :magma :inferno], linez = x,
        colorbar = false, legend =:false, xlab =L"x")
    Plots.plot(plt1, plt2, plt3, plt4, layout = (2,2), legendfont=(8,))
end
test_plots_layout()
Figure 3: Test plots layout.


CC BY-NC-SA 4.0 Jose Storopoli, Rik Huijzer and Lazaro Alonso