Skip to content

Commit

Permalink
plot2d: deal with neurons without soma
Browse files Browse the repository at this point in the history
  • Loading branch information
schlegelp committed Nov 16, 2020
1 parent 679643b commit 5c556ea
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions navis/plotting/dd.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,11 +134,14 @@ def plot2d(x: Union[core.NeuronObject,
>>> ax.elev = 45
>>> # Move camera closer (will make image bigger)
>>> ax.dist = 5
>>> plt.show()
>>> plt.show() # doctest: +SKIP
Plot using depth-coloring
>>> fig, ax = navis.plot2d(nl, method='3d', depth_coloring=True)
>>> plt.show()
>>> plt.show() # doctest: +SKIP
To close all figures
>>> plt.close('all')
Returns
Expand Down Expand Up @@ -496,7 +499,8 @@ def set_depth():
# No need for normaliser - already happened
c.set_norm(None)

if isinstance(neuron, core.TreeNeuron) and not isinstance(neuron.soma, type(None)):
if (isinstance(neuron, core.TreeNeuron)
and not isinstance(getattr(neuron, 'soma', None), type(None))):
# Get depth of soma(s)
soma = utils.make_iterable(neuron.soma)
soma_co = neuron.nodes.set_index('node_id').loc[soma][['x', 'y', 'z']].values
Expand Down Expand Up @@ -876,7 +880,8 @@ def _plot_skeleton(neuron, color, method, ax, **kwargs):
line3D_collection = None

surf3D_collections = []
if plot_soma and not isinstance(neuron.soma, type(None)):
if plot_soma and not isinstance(getattr(neuron, 'soma', None),
type(None)):
soma = utils.make_iterable(neuron.soma)
# If soma detection is messed up we might end up producing
# dozens of soma which will freeze the kernel
Expand Down

0 comments on commit 5c556ea

Please sign in to comment.