Skip to content

Axis3

Attributes

alignmode

Defaults to Inside()

The alignment of the scene in its suggested bounding box.

aspect

Defaults to (1.0, 1.0, 2 / 3)

Controls the lengths of the three axes relative to each other.

Options are:

  • A three-tuple of numbers, which sets the relative lengths of the x, y and z axes directly

  • :data which sets the length ratios equal to the limit ratios of the axes. This results in an "unsquished" look where a cube in data space looks like a cube and not a cuboid.

  • :equal which is a shorthand for (1, 1, 1)

julia
using CairoMakie
fig = Figure()

Axis3(fig[1, 1], aspect = (1, 1, 1), title = "aspect = (1, 1, 1)")
Axis3(fig[1, 2], aspect = (2, 1, 1), title = "aspect = (2, 1, 1)")
Axis3(fig[2, 1], aspect = (1, 2, 1), title = "aspect = (1, 2, 1)")
Axis3(fig[2, 2], aspect = (1, 1, 2), title = "aspect = (1, 1, 2)")

fig
julia
using CairoMakie
using FileIO

fig = Figure()

brain = load(assetpath("brain.stl"))

ax1 = Axis3(fig[1, 1], aspect = :equal, title = "aspect = :equal")
ax2 = Axis3(fig[1, 2], aspect = :data, title = "aspect = :data")

for ax in [ax1, ax2]
    mesh!(ax, brain, color = :gray80)
end

fig

azimuth

Defaults to 1.275pi

The azimuth (left / right) angle of the camera.

At azimuth = 0, the camera looks at the axis from a point on the positive x axis, and rotates to the right from there with increasing values. At the default value 1.275π, the x axis goes to the right and the y axis to the left.

julia
using CairoMakie
fig = Figure()

for (i, azimuth) in enumerate([0, 0.1, 0.2, 0.3, 0.4, 0.5])
    Axis3(fig[fldmod1(i, 3)...], azimuth = azimuth * pi,
        title = "azimuth = $(azimuth)π", viewmode = :fit)
end

fig

backgroundcolor

Defaults to :transparent

The background color

dim1_conversion

Defaults to nothing

Global state for the x dimension conversion.

dim2_conversion

Defaults to nothing

Global state for the y dimension conversion.

dim3_conversion

Defaults to nothing

Global state for the z dimension conversion.

elevation

Defaults to pi / 8

The elevation (up / down) angle of the camera. Possible values are between -pi/2 (looking from the bottom up) and +pi/2 (looking from the top down).

julia
using CairoMakie
fig = Figure()

for (i, elevation) in enumerate([0, 0.05, 0.1, 0.15, 0.2, 0.25])
    Axis3(fig[fldmod1(i, 3)...], elevation = elevation * pi,
        title = "elevation = $(elevation)π", viewmode = :fit)
end

fig

halign

Defaults to :center

The horizontal alignment of the scene in its suggested bounding box.

height

Defaults to nothing

The height setting of the scene.

limits

Defaults to (nothing, nothing, nothing)

The limits that the user has manually set. They are reinstated when calling reset_limits! and are set to nothing by autolimits!. Can be either a tuple (xlow, xhigh, ylow, yhigh, zlow, zhigh) or a tuple (nothing_or_xlims, nothing_or_ylims, nothing_or_zlims). Are set by xlims!, ylims!, zlims! and limits!.

perspectiveness

Defaults to 0.0

This setting offers a simple scale from 0 to 1, where 0 looks like an orthographic projection (no perspective) and 1 is a strong perspective look. For most data visualization applications, perspective should be avoided because it makes interpreting the data correctly harder. It can be of use, however, if aesthetics are more important than neutral presentation.

julia
using CairoMakie
fig = Figure()

for (i, perspectiveness) in enumerate(range(0, 1, length = 6))
    ax = Axis3(fig[fldmod1(i, 3)...]; perspectiveness, protrusions = (0, 0, 0, 15),
        title = ":perspectiveness = $(perspectiveness)")
    hidedecorations!(ax)
end

fig

protrusions

Defaults to 30

The protrusions control how much gap space is reserved for labels etc. on the sides of the Axis3. Unlike Axis, Axis3 currently does not set these values automatically depending on the properties of ticks and labels. This is because the effective protrusions also depend on the rotation and scaling of the axis cuboid, which changes whenever the Axis3 shifts in the layout. Therefore, auto-updating protrusions could lead to an endless layout update cycle.

The default value of 30 for all sides is just a heuristic and might lead to collisions of axis decorations with the Figure boundary or other plot elements. If that's the case, you can try increasing the value(s).

The protrusions attribute accepts a single number for all sides, or a tuple of (left, right, bottom, top).

julia
using CairoMakie
    fig = Figure(backgroundcolor = :gray97)
    Box(fig[1, 1], strokewidth = 0) # visualizes the layout cell
    Axis3(fig[1, 1], protrusions = 100, viewmode = :stretch,
        title = "protrusions = 100")
    fig
julia
using CairoMakie
    fig = Figure(backgroundcolor = :gray97)
    Box(fig[1, 1], strokewidth = 0) # visualizes the layout cell
    ax = Axis3(fig[1, 1], protrusions = (0, 0, 0, 20), viewmode = :stretch,
        title = "protrusions = (0, 0, 0, 20)")
    hidedecorations!(ax)
    fig

targetlimits

Defaults to Rect3f(Vec3f(0, 0, 0), Vec3f(1, 1, 1))

The limits that the axis tries to set given other constraints like aspect. Don't set this directly, use xlims!, ylims! or limits! instead.

tellheight

Defaults to true

Controls if the parent layout can adjust to this element's height

tellwidth

Defaults to true

Controls if the parent layout can adjust to this element's width

title

Defaults to ""

The axis title string.

titlealign

Defaults to :center

The horizontal alignment of the title.

titlecolor

Defaults to @inherit :textcolor :black

The color of the title

titlefont

Defaults to :bold

The font family of the title.

titlegap

Defaults to 4.0

The gap between axis and title.

titlesize

Defaults to @inherit :fontsize 16.0f0

The title's font size.

titlevisible

Defaults to true

Controls if the title is visible.

valign

Defaults to :center

The vertical alignment of the scene in its suggested bounding box.

viewmode

Defaults to :fitzoom

The view mode affects the final projection of the axis by fitting the axis cuboid into the available space in different ways.

  • :fit uses a fixed scaling such that a tight sphere around the cuboid touches the frame edge. This means that the scaling doesn't change when rotating the axis (the apparent size of the axis stays the same), but not all available space is used. The chosen aspect is maintained using this setting.

  • :fitzoom uses a variable scaling such that the closest cuboid corner touches the frame edge. When rotating the axis, the apparent size of the axis changes which can result in a "pumping" visual effect. The chosen aspect is also maintained using this setting.

  • :stretch pulls the cuboid corners to the frame edges such that the available space is filled completely. The chosen aspect is not maintained using this setting, so :stretch should not be used if a particular aspect is needed.

julia
using CairoMakie
fig = Figure()

for (i, viewmode) in enumerate([:fit, :fitzoom, :stretch])
    for (j, elevation) in enumerate([0.1, 0.2, 0.3] .* pi)

        Label(fig[i, 1:3, Top()], "viewmode = $(repr(viewmode))", font = :bold)

        # show the extent of each cell using a box
        Box(fig[i, j], strokewidth = 0, color = :gray95)

        ax = Axis3(fig[i, j]; viewmode, elevation, protrusions = 0, aspect = :equal)
        hidedecorations!(ax)

    end
end

fig

width

Defaults to nothing

The width setting of the scene.

xautolimitmargin

Defaults to (0.05, 0.05)

The relative margins added to the autolimits in x direction.

xgridcolor

Defaults to RGBAf(0, 0, 0, 0.12)

The x grid color

xgridvisible

Defaults to true

Controls if the x grid is visible

xgridwidth

Defaults to 1

The x grid width

xlabel

Defaults to "x"

The x label

xlabelalign

Defaults to Makie.automatic

The x label align

xlabelcolor

Defaults to @inherit :textcolor :black

The x label color

xlabelfont

Defaults to :regular

The x label font

xlabeloffset

Defaults to 40

The x label offset

xlabelrotation

Defaults to Makie.automatic

The x label rotation in radians

xlabelsize

Defaults to @inherit :fontsize 16.0f0

The x label size

xlabelvisible

Defaults to true

Controls if the x label is visible

xreversed

Defaults to false

Controls if the x axis goes rightwards (false) or leftwards (true) in default camera orientation.

julia
using CairoMakie
using FileIO

fig = Figure()

brain = load(assetpath("brain.stl"))

ax1 = Axis3(fig[1, 1], title = "xreversed = false")
ax2 = Axis3(fig[2, 1], title = "xreversed = true", xreversed = true)
for ax in [ax1, ax2]
    mesh!(ax, brain, color = getindex.(brain.position, 1))
end

fig

xspinecolor_1

Defaults to :black

The color of x spine 1 where the ticks are displayed

xspinecolor_2

Defaults to :black

The color of x spine 2 towards the center

xspinecolor_3

Defaults to :black

The color of x spine 3 opposite of the ticks

xspinesvisible

Defaults to true

Controls if the x spine is visible

xspinewidth

Defaults to 1

The x spine width

xtickcolor

Defaults to :black

The x tick color

xtickformat

Defaults to Makie.automatic

The x tick format

xticklabelcolor

Defaults to @inherit :textcolor :black

The x ticklabel color

xticklabelfont

Defaults to :regular

The x ticklabel font

xticklabelpad

Defaults to 5

The x ticklabel pad

xticklabelsize

Defaults to @inherit :fontsize 16.0f0

The x ticklabel size

xticklabelsvisible

Defaults to true

Controls if the x ticklabels are visible

xticks

Defaults to WilkinsonTicks(5; k_min = 3)

The x ticks

xticksize

Defaults to 6

The size of the xtick marks.

xticksvisible

Defaults to true

Controls if the x ticks are visible

xtickwidth

Defaults to 1

The x tick width

xypanelcolor

Defaults to :transparent

The color of the xy panel

xypanelvisible

Defaults to true

Controls if the xy panel is visible

xzpanelcolor

Defaults to :transparent

The color of the xz panel

xzpanelvisible

Defaults to true

Controls if the xz panel is visible

yautolimitmargin

Defaults to (0.05, 0.05)

The relative margins added to the autolimits in y direction.

ygridcolor

Defaults to RGBAf(0, 0, 0, 0.12)

The y grid color

ygridvisible

Defaults to true

Controls if the y grid is visible

ygridwidth

Defaults to 1

The y grid width

ylabel

Defaults to "y"

The y label

ylabelalign

Defaults to Makie.automatic

The y label align

ylabelcolor

Defaults to @inherit :textcolor :black

The y label color

ylabelfont

Defaults to :regular

The y label font

ylabeloffset

Defaults to 40

The y label offset

ylabelrotation

Defaults to Makie.automatic

The y label rotation in radians

ylabelsize

Defaults to @inherit :fontsize 16.0f0

The y label size

ylabelvisible

Defaults to true

Controls if the y label is visible

yreversed

Defaults to false

Controls if the y axis goes leftwards (false) or rightwards (true) in default camera orientation.

julia
using CairoMakie
using FileIO

fig = Figure()

brain = load(assetpath("brain.stl"))

ax1 = Axis3(fig[1, 1], title = "yreversed = false")
ax2 = Axis3(fig[2, 1], title = "yreversed = true", yreversed = true)
for ax in [ax1, ax2]
    mesh!(ax, brain, color = getindex.(brain.position, 2))
end

fig

yspinecolor_1

Defaults to :black

The color of y spine 1 where the ticks are displayed

yspinecolor_2

Defaults to :black

The color of y spine 2 towards the center

yspinecolor_3

Defaults to :black

The color of y spine 3 opposite of the ticks

yspinesvisible

Defaults to true

Controls if the y spine is visible

yspinewidth

Defaults to 1

The y spine width

ytickcolor

Defaults to :black

The y tick color

ytickformat

Defaults to Makie.automatic

The y tick format

yticklabelcolor

Defaults to @inherit :textcolor :black

The y ticklabel color

yticklabelfont

Defaults to :regular

The y ticklabel font

yticklabelpad

Defaults to 5

The y ticklabel pad

yticklabelsize

Defaults to @inherit :fontsize 16.0f0

The y ticklabel size

yticklabelsvisible

Defaults to true

Controls if the y ticklabels are visible

yticks

Defaults to WilkinsonTicks(5; k_min = 3)

The y ticks

yticksize

Defaults to 6

The size of the ytick marks.

yticksvisible

Defaults to true

Controls if the y ticks are visible

ytickwidth

Defaults to 1

The y tick width

yzpanelcolor

Defaults to :transparent

The color of the yz panel

yzpanelvisible

Defaults to true

Controls if the yz panel is visible

zautolimitmargin

Defaults to (0.05, 0.05)

The relative margins added to the autolimits in z direction.

zgridcolor

Defaults to RGBAf(0, 0, 0, 0.12)

The z grid color

zgridvisible

Defaults to true

Controls if the z grid is visible

zgridwidth

Defaults to 1

The z grid width

zlabel

Defaults to "z"

The z label

zlabelalign

Defaults to Makie.automatic

The z label align

zlabelcolor

Defaults to @inherit :textcolor :black

The z label color

zlabelfont

Defaults to :regular

The z label font

zlabeloffset

Defaults to 50

The z label offset

zlabelrotation

Defaults to Makie.automatic

The z label rotation in radians

zlabelsize

Defaults to @inherit :fontsize 16.0f0

The z label size

zlabelvisible

Defaults to true

Controls if the z label is visible

zreversed

Defaults to false

Controls if the z axis goes upwards (false) or downwards (true) in default camera orientation.

julia
using CairoMakie
using FileIO

fig = Figure()

brain = load(assetpath("brain.stl"))

ax1 = Axis3(fig[1, 1], title = "zreversed = false")
ax2 = Axis3(fig[2, 1], title = "zreversed = true", zreversed = true)
for ax in [ax1, ax2]
    mesh!(ax, brain, color = getindex.(brain.position, 3))
end

fig

zspinecolor_1

Defaults to :black

The color of z spine 1 where the ticks are displayed

zspinecolor_2

Defaults to :black

The color of z spine 2 towards the center

zspinecolor_3

Defaults to :black

The color of z spine 3 opposite of the ticks

zspinesvisible

Defaults to true

Controls if the z spine is visible

zspinewidth

Defaults to 1

The z spine width

ztickcolor

Defaults to :black

The z tick color

ztickformat

Defaults to Makie.automatic

The z tick format

zticklabelcolor

Defaults to @inherit :textcolor :black

The z ticklabel color

zticklabelfont

Defaults to :regular

The z ticklabel font

zticklabelpad

Defaults to 10

The z ticklabel pad

zticklabelsize

Defaults to @inherit :fontsize 16.0f0

The z ticklabel size

zticklabelsvisible

Defaults to true

Controls if the z ticklabels are visible

zticks

Defaults to WilkinsonTicks(5; k_min = 3)

The z ticks

zticksize

Defaults to 6

The size of the ztick marks.

zticksvisible

Defaults to true

Controls if the z ticks are visible

ztickwidth

Defaults to 1

The z tick width