Axis

The axis is just a scene object, making it easy to manipulate and share between plots. Axis objects also contains the mapping you want to apply to the data and can interactively be changed. An Axis object can be created from any boundingbox and inserted into any plot.

There are two types of axes: Axis2D and Axis3D.

Interacting with the Axis

One can quite easily interact with the attributes of the axis like with any other plot.

You can access the axis of a scene by doing

axis = scene[Axis]

The axis attributes are nested, and there are different attributes depending on whether it is an Axis2D or Axis3D object.

You can access the nested attributes in multiple ways. Take the nested attribute axis -> :names -> :axisnames, for example:

  1. axis[:names, :axisnames] = ("x", "y", "z")
  2. axis[:names][:axisnames] = ("x", "y", "z")
  3. axis = (names = (axisnames = ("x", "y", "z"),),)

Axis2D

Axis2D attributes groups

SymbolDescription
frameSee the detailed descriptions for frame attributes.
gridSee the detailed descriptions for grid attributes.
namesSee the detailed descriptions for names attributes.
ticksSee the detailed descriptions for ticks attributes.

:grid

SymbolDescription
linecolorSymbol or Colorant. Specifies the color of the grid lines. Can be a color symbol/string like :red, or a Colorant.
linestyle
linewidthNTuple{2, Number}. Width of the x and y grids.

:ticks

SymbolDescription
alignNTuple{2,(:pos, :pos)}. Specify the text alignment for the axis ticks, where :pos can be :left, :center, or :right
fontNTuple{2,String}. Specifies the font and can name any font available on the system.
gapNumber. Specifies the gap (in pixels) between the axis tick labels and the axes themselves.
linecolorNTuple{2,Symbol or Colorant}. Specifies the color of the grid lines. Can be a color symbol/string like :red, or a Colorant.
linestyle
linewidthNTuple{2,Number}. Width of the axes ticks.
rotationNTuple{3,Float32}. Specifies the rotations for each axis's ticks, in radians.
textcolorNTuple{2,Symbol or Colorant}. Specifies the color of the axes ticks. Can be a color symbol/string like :red, or a Colorant.
textsizeNTuple{2,Int}. Font pointsize for tick labels.
title_gapNumber. Specifies the gap (in pixels) between the axis titles and the axis tick labels.

:frame

SymbolDescription
arrow_sizeNumber. Size of the axes arrows.
axis_arrowBool. Toggles the axes arrows.
axis_position
framesNTuple{2,NTuple{2,Bool}}.
linecolorSymbol or Colorant. Specifies the color of the grid lines. Can be a color symbol/string like :red, or a Colorant.
linestyle
linewidthNumber. Widths of the axes frame lines.

:names

SymbolDescription
align(:pos, :pos). Specify the text alignment, where :pos can be :left, :center, or :right.
axisnamesNTuple{2,String}. Specifies the text labels for the axes.
fontNTuple{2,String}. Specifies the font and can name any font available on the system.
rotationNTuple{3,Float32}. Specifies the rotations for each axis's label, in radians.
textcolorNTuple{2,Symbol or Colorant}. Specifies the color of the axes labels. Can be a color symbol/string like :red, or a Colorant.
textsizeInteger. Font pointsize for text.

Axis3D

Axis3D attributes groups

SymbolDescription
frameSee the detailed descriptions for frame attributes.
namesSee the detailed descriptions for names attributes.
scaleNTuple{3,Float}. Specifies the scaling for the axes.
showaxisNTuple{3,Bool}. Specifies whether to show the axes.
showgridNTuple{3,Bool}. Specifies whether to show the axis grids.
showticksNTuple{3,Bool}. Specifies whether to show the axis ticks.
ticksSee the detailed descriptions for ticks attributes.

:ticks

SymbolDescription
alignNTuple{3,(:pos, :pos)}. Specify the text alignment for the axis ticks, where :pos can be :left, :center, or :right.
fontNTuple{3,String}. Specifies the font for the axis ticks, and can choose any font available on the system.
gapNumber. Specifies the gap (in pixels) between the axis ticks and the axes themselves.
rotationNTuple{3,Quaternion{Float32}}. Specifies the rotations for each axis's ticks, in radians.
textcolorNTuple{3,Symbol or Colorant}. Specifies the color of the axes ticks. Can be a color symbol/string like :red, or a Colorant.
textsizeInteger. Font pointsize for text.

:frame

SymbolDescription
axiscolorSymbol or Colorant. Specifies the color of the axes. Can be a color symbol/string like :red, or a Colorant.
linecolorSymbol or Colorant. Specifies the color of the grid lines. Can be a color symbol/string like :red, or a Colorant.
linewidthNumber. Width of the axes lines.

:names

SymbolDescription
alignNTuple{3,(:pos, :pos)}. Specify the text alignment for the axis labels, where :pos can be :left, :center, or :right.
axisnamesNTuple{3,String}. Specifies the axis labels.
fontNTuple{3,String}. Specifies the font for the axis labels, and can choose any font available on the system.
gapNumber. Specifies the gap (in pixels) between the axis labels and the axes themselves.
rotationNTuple{3,Quaternion{Float32}}. Specifies the rotations for each axis's label, in radians.
textcolorNTuple{3,Symbol or Colorant}. Specifies the color of the axes labels. Can be a color symbol/string like :red, or a Colorant.
textsizeNTuple{3,Int}. Font pointsize for axes labels.

Examples

using Makie

 scene = Scene(resolution = (500, 500))
 scatter!(scene, Point3f0[(1,0,0), (0,1,0), (0,0,1)], marker = [:x, :circle, :cross])

using Makie

 vx = -1:0.01:1
 vy = -1:0.01:1

 f(x, y) = (sin(x*10) + cos(y*10)) / 4
 scene = Scene(resolution = (500, 500))
 # One way to style the axis is to pass a nested dictionary / named tuple to it.
 surface!(scene, vx, vy, f, axis = (frame = (linewidth = 2.0,),))
 psurf = scene[end] # the surface we last plotted to scene
 # One can also directly get the axis object and manipulate it
 axis = scene[Axis] # get axis

 # You can access nested attributes likes this:
 axis[:names, :axisnames] = ("\\bf{ℜ}[u]", "\\bf{𝕴}[u]", " OK\n\\bf{δ}\n γ")
 tstyle = axis[:names] # or just get the nested attributes and work directly with them

 tstyle[:textsize] = 10
 tstyle[:textcolor] = (:red, :green, :black)
 tstyle[:font] = "helvetica"


 psurf[:colormap] = :RdYlBu
 wh = widths(scene)
 t = text!(
     campixel(scene),
     "Multipole Representation of first resonances of U-238",
     position = (wh[1] / 2.0, wh[2] - 20.0),
     align = (:center,  :center),
     textsize = 20,
     font = "helvetica",
     raw = :true
 )
 c = lines!(scene, Circle(Point2f0(0.1, 0.5), 0.1f0), color = :red, offset = Vec3f0(0, 0, 1))
 scene
 #update surface
 # TODO explain and improve the situation here
 psurf.converted[3][] = f.(vx .+ 0.5, (vy .+ 0.5)')
 scene

using Makie
 using GeometryTypes

 scene = Scene()
 points = decompose(Point2f0, Circle(Point2f0(10), 10f0), 9)
 lines!(
     scene,
     points,
     linewidth = 8,
     color = :black
 )

 axis = scene[Axis] # get axis
 scene

 st = Stepper(scene, "axis_theming")
 step!(st);
 axis[:frame][:linewidth] = 5
 step!(st)
 axis[:grid][:linewidth] = (1, 5)
 step!(st)
 axis[:grid][:linecolor] = ((:red, 0.3), (:blue, 0.5))
 step!(st)
 axis[:names][:axisnames] = ("x", "y   ")
 step!(st)
 axis[:ticks][:title_gap] = 1
 step!(st)
 axis[:names][:rotation] = (0.0, -3/8*pi)
 step!(st)
 axis[:names][:textcolor] = ((:red, 1.0), (:blue, 1.0))
 step!(st)
 axis[:ticks][:font] = ("Dejavu Sans", "Helvetica")
 step!(st)
 axis[:ticks][:rotation] = (0.0, -pi/2)
 step!(st)
 axis[:ticks][:textsize] = (3, 7)
 step!(st)
 axis[:ticks][:gap] = 5
 step!(st)