Plot neurons in 3D using rgl library or plotly module

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



A neuron to plot


Whether to plot lines for all segments in neuron


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


Whether to plot dots for branch and end points


Whether to plot dots for all points in the neuron


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


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


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


Colour specification (see rgl materials)


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).


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


list of rgl plotting ids (invisibly) separated into lines, points, texts according to plot element. See rgl::plot3d for 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.

See also


# A new plot would have been opened if required open3d()
#> glX #> 7
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) # }