Skip to content

Recipes

trajectory

TimeseriesMakie.trajectory Function
julia
trajectory(x, y, [z]; kwargs...)

Plots a colored trajectory in 2D or 3D space.

Key attribtues:

color = :speed: The coloring method for the trajectory.

Can be one of:

  • :speed: Color by speed along the trajectory

  • :time: Color by time index

  • <: AbstractVector: Color by a custom vector of values

  • Union{<:Symbol, <:Colorant}: Color by a fixed color

Other attributes are shared with Makie.Lines.

Plot type

The plot type alias for the trajectory function is Trajectory.

source
julia
f = Figure(size = (600, 600))

ϕ = 0:0.1:() |> reverse
x = ϕ .* exp.(ϕ .* im)
y = imag.(x)
x = real.(x)

# * Default
ax = Axis(f[1, 1], title = "Default")
trajectory!(ax, x, y)

# * Speed
ax = Axis(f[1, 2], title = "Speed")
trajectory!(ax, x, y; color = :speed)

# * Alpha
ax = Axis(f[2, 1], title = "Time")
trajectory!(ax, x, y; color = :time)

# * 3D
ax = Axis3(f[2, 2], title = "3D")
trajectory!(ax, x, y, x .* y; color = :speed)

f

shadows

TimeseriesMakie.shadows Function
julia
shadows(x, y, z; kwargs...)

Plots shadows of a 3D trajectory onto the enclosing axis panes.

Key attributes:

mode = :projection: The shadowing mode

swapshadows = automatic: Whether to swap the axes for each shadow.

Can be:

  • true or false: Swap the axes for all shadows from their default values

  • NTuple{3, Bool}: Swap the default axes for each shadow individually (x, y, z)

  • automatic: Defaults to (true, true, false)

limits = automatic: The targeted axis limits. To ensure the shadows align with the axes, it is best to provide the Axis limits here. If automatic, the limits are inferred from the data.

Other attributes are shared with Makie.Lines.

Plot type

The plot type alias for the shadows function is Shadows.

source
julia
 f = Figure(size = (500, 500))

ϕ = 0:0.1:() |> reverse
x = ϕ .* exp.(ϕ .* im)
y = imag.(x)
x = real.(x)
z = x .* y

limits = (extrema(x), extrema(y), extrema(z))
ax = Axis3(f[1, 1]; title = "Shadows", limits)
lines!(ax, x, y, z)
shadows!(ax, x, y, z; limits, linewidth = 0.5)

f

traces

TimeseriesMakie.traces Function
julia
traces(x, y, Z; kwargs...)

Plot the columns of Z over the domain x, colored by y.

Key attributes:

  • linecolor = automatic: Sets the color of the traces.

  • spacing = 0: The spacing between traces.

Can be a number in data space, or one of the following modes: - :even: Even spacing equal to the greatest difference between traces. - :close: Successive traces are spaced by the smallest difference between them.

  • offset = 1: The offset factor (offset * spacing)

Other attributes are shared with Makie.Lines.

Plot type

The plot type alias for the traces function is Traces.

source
julia
f = Figure(size = (900, 300))

x = 0:0.1:10
y = range(0, π, length = 5)
Z = [sin.(x .+ i) for i in y]
Z = stack(Z)

ax = Axis(f[1, 1]; title = "Unstacked")
p = traces!(ax, x, y, Z)
Colorbar(f[1, 2], p)

ax = Axis(f[1, 3]; title = "Even")
p = traces!(ax, x, y, Z; spacing = :even, offset = 1.5)
Colorbar(f[1, 4], p)

ax = Axis(f[1, 5]; title = "Close")
p = traces!(ax, x, y, Z; spacing = :close, offset = 1.5)
Colorbar(f[1, 6], p)

f

kinetic

TimeseriesMakie.kinetic Function
julia
kinetic(x, y; kwargs...)

Plots a line with a varying width.

Key attribtues:

linewidth = :curv:

Sets the algorithm for determining the line width.

  • :curv - Width is determined by the velocity

  • :x - Width is determined by the x-coordinate

  • :y - Width is determined by the y-coordinate

  • <: Number - Width is set to a constant value

linewidthscale = 1: Scale factor for the line width.

Other attributes are shared with Makie.Lines.

Plot type

The plot type alias for the kinetic function is Kinetic.

source
julia
x = -π:0.1:π
kinetic(x, sin.(x))