Makie: Multiline plots, subplots and attributes examples

Thx, we definitively need more short examples.

My quick cheat sheet:

using GLMakie
GLMakie.activate!()

# Makie hierarchy is figure, axis, plot
# 1) direct plot call via lines() or scatter() 
lines(0:0.1:10, sin)               # plot lines figure
fap = lines(0:0.1:10, sin)         # return Makie.FigureAxisPlot object
# ?fap                             # show help for Makie.FigureAxisPlot
fieldnames(typeof(fap))            # (:figure, :axis, :plot)
fap.plot.attributes                # show all properties of plot
fap.plot[:color] = :red            # change the color property of plot
f,a,p = fap                        # destruction in Julia
# 2) direct plot, return components
f,a,p = lines(0:0.1:10, sin)       # figure, axis, plots
# ?f, ?a, ?p                       # show help for figure, axis, plots objects
p[:color] = :red                   # change the color property of plot
p2 = lines!(0:0.1:10, cos)         # add plot, returns plot object
p2.color = :red                    # change the color property of plot
# 3) Hierarchical composition
f = Figure()                       # create figure pane
a = Axis(f[1, 1])                  # create axis at position [1,1] 
p = []                             # if you want to index plots or axes, start empty
push!(p, lines!(a, 0:0.1:10, sin)) # plot lines figure in current axis, mind the !
push!(p, lines!(a, 0:0.1:10, cos)) # add another plot
p[2][:color] = :red                # change the color property of second plot
p[2].color = :red                  # change the color property of second plot
6 Likes