Plot neurons in 3D using rgl library or plotly module

# S3 method for neuron
plot3d(
  x,
  WithLine = TRUE,
  NeuronNames = FALSE,
  WithNodes = TRUE,
  WithAllPoints = FALSE,
  WithText = FALSE,
  PlotSubTrees = TRUE,
  add = TRUE,
  col = NULL,
  soma = FALSE,
  ...,
  gridlines = FALSE,
  plotengine = getOption("nat.plotengine")
)

Arguments

x

A neuron to plot

WithLine

Whether to plot lines for all segments in neuron

NeuronNames

Logical indicating whether to label the neuron in the plot using the NeuronName field or a character vector of names.

WithNodes

Whether to plot dots for branch and end points

WithAllPoints

Whether to plot dots for all points in the neuron

WithText

Whether to label plotted points with their numeric id (see details)

PlotSubTrees

Whether to plot all sub trees when the neuron is not fully connected.

add

Whether to add the neuron to existing rgl plot rather than clearing the scene (default TRUE)

col

Colour specification (see rgl materials)

soma

Whether to plot a sphere at neuron's origin representing the soma. Either a logical value or a numeric indicating the radius (default FALSE). When soma=TRUE the radius is hard coded to 2.

...

Additional arguments passed to lines3d (and spheres3d if somata are being plotted).

gridlines

Whether to display gridlines when using plotly as the backend plotting engine (default: FALSE)

plotengine

the plotting backend engine to use either 'rgl' or 'plotly'.

Value

list of rgl plotting ids (invisibly) separated into lines, points, texts according to plot element. See rgl::plot3d for details.

Details

Note that when WithText=TRUE, the numeric identifiers plotted are raw indices into the x$d array of the neuron, not the values of the PointNo column.

Note that ... is passed to both lines3d and spheres3d (if somata are being plotted). Not all ... elements are necessarily relevant to both of these drawing calls. Furthermore plotting a large number of somata with transparency (i.e. alpha < 1 ) can quickly result in very slow rgl draw and refresh speeds; you will likely want to set skipRedraw=FALSE when using plot3d.neuronlist to plot a collection of neurons.

Examples

# A new plot would have been opened if required
open3d()
plot3d(Cell07PNs[[1]],col='red')
plot3d(Cell07PNs[[2]],col='green')
# \donttest{
# clear the current plot
nclear3d()
plot3d(Cell07PNs[[2]],col='blue',add=FALSE)
# plot the number of all nodes
nclear3d()
plot3d(Cell07PNs[[2]],col='red',WithText=TRUE,add=FALSE)
# include cell bodies
plot3d(Cell07PNs[3:4], col='red', soma=TRUE)
plot3d(Cell07PNs[5], col='red', soma=3)
# }