Skip to contents

Modification of rgl::axis3d() that adds two extra parameters, ticksize and labeldist, to independently control the length of the axis tick marks and the distance between those tick marks and their labels. Based on the solution proposed on Stack Overflow (see References).

Usage

axis3(
  edge,
  at = NULL,
  labels = TRUE,
  tick = TRUE,
  line = TRUE,
  pos = NULL,
  nticks = 5,
  ticksize = 0.05,
  labeldist = 3,
  ...
)

Arguments

edge

character string indicating the edge of the bounding box on which the axis is drawn (same format as in rgl::axis3d(), e.g. "z+-").

at

positions at which the tick marks are drawn; if NULL they are computed automatically with pretty().

labels

tick labels: logical, indicating whether to automatically label the axes or be omitted, or a vector of labels.

tick

logical; if TRUE the axis tick marks are drawn.

line

logical; if TRUE the axis line is drawn.

pos

optional position of the axis (see rgl::axis3d()).

nticks

approximate number of tick marks when at = NULL.

ticksize

length of the tick marks, as a fraction of the distance to the center of the scene's range.

labeldist

distance between the tick marks and the labels, as a multiple of ticksize.

...

additional arguments passed to rgl::segments3d() and rgl::text3d().

Value

An rglId object (see rgl::lowlevel()) with the identifiers of the rgl elements added (line, tick marks and labels).

References

Dominic Woolf (2013, Mar 23). R rgl distance between axis ticks and tick labels, Stack Overflow, https://stackoverflow.com/a/39299740/4303451.

Examples

library(rgl)
open3d()
set.seed(1)
points3d(rnorm(100), rnorm(100), rnorm(100))
box3d()
# z axis with longer tick marks and labels closer to them than usual
axis3('z+-', ticksize = 0.5, labeldist = 1)