def draw(obj, mode='<STR_LIT>', **kwargs):
if mode not in MODES:<EOL><INDENT>raise InvalidDrawModeError('<STR_LIT>' % mode)<EOL><DEDENT>if mode in ('<STR_LIT>', '<STR_LIT>'):<EOL><INDENT>fig, ax = common.get_figure()<EOL><DEDENT>else:<EOL><INDENT>fig, ax = common.get_figure(params={'<STR_LIT>': '<STR_LIT>'})<EOL><DEDENT>if isinstance(obj, Neuron):<EOL><INDENT>tag = '<STR_LIT>'<EOL><DEDENT>elif isinstance(obj, (Tree, Neurite)):<EOL><INDENT>tag = '<STR_LIT>'<EOL><DEDENT>elif isinstance(obj, Soma):<EOL><INDENT>tag = '<STR_LIT>'<EOL><DEDENT>else:<EOL><INDENT>raise NotDrawableError('<STR_LIT>' % obj.__class__)<EOL><DEDENT>viewer = '<STR_LIT>' % (tag, mode)<EOL>try:<EOL><INDENT>plotter = _VIEWERS[viewer]<EOL><DEDENT>except KeyError:<EOL><INDENT>raise NotDrawableError('<STR_LIT>' % (obj.__class__, mode))<EOL><DEDENT>output_path = kwargs.pop('<STR_LIT>', None)<EOL>plotter(ax, obj, **kwargs)<EOL>if mode != '<STR_LIT>':<EOL><INDENT>common.plot_style(fig=fig, ax=ax, **kwargs)<EOL><DEDENT>if output_path:<EOL><INDENT>common.save_plot(fig=fig, output_path=output_path, **kwargs)<EOL><DEDENT>return fig, ax<EOL>
Draw a morphology object

    Parameters:
        obj: morphology object to be drawn (neuron, tree, soma).
        mode (Optional[str]): drawing mode ('2d', '3d', 'dendrogram'). Defaults to '2d'.
        **kwargs: keyword arguments for underlying neurom.view.view functions.

    Raises:
        InvalidDrawModeError if mode is not valid
        NotDrawableError if obj is not drawable
        NotDrawableError if obj type and mode combination is not drawable

    Examples:

        >>> nrn = ... # load a neuron
        >>> fig, _ = viewer.draw(nrn)             # 2d plot
        >>> fig.show()
        >>> fig3d, _ = viewer.draw(nrn, mode='3d') # 3d plot
        >>> fig3d.show()
        >>> fig, _ = viewer.draw(nrn.neurites[0]) # 2d plot of neurite tree
        >>> dend, _ = viewer.draw(nrn, mode='dendrogram')