Beispiel #1
0
def plot_somas(somas):
    """Plot set of somas on same figure as spheres, each with different color."""
    _, ax = common.get_figure(new_fig=True, subplot=111,
                              params={'projection': '3d', 'aspect': 'equal'})
    for s in somas:
        common.plot_sphere(ax, s.center, s.radius, color=random_color(), alpha=1)
    plt.show()
Beispiel #2
0
def plot_somas(somas):
    '''Plot set of somas on same figure as spheres, each with different color'''
    _, ax = common.get_figure(new_fig=True, subplot=111,
                              params={'projection': '3d', 'aspect': 'equal'})
    for s in somas:
        common.plot_sphere(ax, s.center, s.radius, color=random_color(), alpha=1)
    plt.show()
Beispiel #3
0
def plot_soma3d(ax, soma, color=None, alpha=_ALPHA):
    """Generates a 3d figure of the soma.

    Args:
        ax(matplotlib axes): on what to plot
        soma(neurom.core.Soma): plotted soma
        color(str or None): Color of plotted values, None corresponds to default choice
        alpha(float): Transparency of plotted values
    """
    color = _get_color(color, tree_type=NeuriteType.soma)

    if isinstance(soma, SomaCylinders):
        for start, end in zip(soma.points, soma.points[1:]):
            common.plot_cylinder(ax,
                                 start=start[COLS.XYZ],
                                 end=end[COLS.XYZ],
                                 start_radius=start[COLS.R],
                                 end_radius=end[COLS.R],
                                 color=color,
                                 alpha=alpha)
    else:
        common.plot_sphere(ax,
                           center=soma.center[COLS.XYZ],
                           radius=soma.radius,
                           color=color,
                           alpha=alpha)

    # unlike w/ 2d Axes, the dataLim isn't set by collections, so it has to be updated manually
    _update_3d_datalim(ax, soma)
Beispiel #4
0
def plot_somas(somas):
    """Plot set of somas on same figure as spheres, each with different color"""
    fig, ax = common.get_figure(new_fig=True, subplot=111, params={"projection": "3d", "aspect": "equal"})
    for s in somas:
        center = s.center
        radius = s.radius
        common.plot_sphere(fig, ax, center, radius, color=random_color(), alpha=1)
    plt.show()
Beispiel #5
0
def soma3d(sm, new_fig=True, new_axes=True, subplot=False, **kwargs):
    '''Generates a 3d figure of the soma.

    Parameters:
        soma: Soma
        neurom.Soma object

    Options:
        alpha: float \
            Defines throughe transparency of the tree. \
            0.0 transparent through 1.0 opaque. \
            Default value is 0.8.
        treecolor: str or None \
            Defines the color of the soma. \
            Soma : "black". \
            Default value is None.
        new_fig: boolean \
            Defines if the tree will be plotted \
            in the current figure (False) \
            or in a new figure (True) \
            Default value is True.
        subplot: matplotlib subplot value or False \
            If False the default subplot 111 will be used. \
            For any other value a matplotlib subplot \
            will be generated. \
            Default value is False.

    Returns:
        A 3D matplotlib figure with a soma view.
    '''
    treecolor = kwargs.get('treecolor', None)

    # Initialization of matplotlib figure and axes.
    fig, ax = common.get_figure(new_fig=new_fig, new_axes=new_axes,
                                subplot=subplot, params={'projection': '3d'})

    # Definition of the tree color depending on the tree type.
    treecolor = common.get_color(treecolor, tree_type=TreeType.soma)

    xs = sm.center[0]
    ys = sm.center[1]
    zs = sm.center[2]

    # Plot the soma as a circle.
    fig, ax = common.plot_sphere(fig, ax, center=[xs, ys, zs], radius=sm.radius, color=treecolor,
                                 alpha=get_default('alpha', **kwargs))

    kwargs['title'] = kwargs.get('title', 'Soma view')
    kwargs['xlabel'] = kwargs.get('xlabel', 'X')
    kwargs['ylabel'] = kwargs.get('ylabel', 'Y')
    kwargs['zlabel'] = kwargs.get('zlabel', 'Z')

    return common.plot_style(fig=fig, ax=ax, **kwargs)
Beispiel #6
0
def soma3d(sm, new_fig=True, new_axes=True, subplot=False, **kwargs):
    """Generates a 3d figure of the soma.

    Parameters:
        soma: Soma
        neurom.Soma object

    Options:
        alpha: float \
            Defines throughe transparency of the tree. \
            0.0 transparent through 1.0 opaque. \
            Default value is 0.8.
        treecolor: str or None \
            Defines the color of the soma. \
            Soma : "black". \
            Default value is None.
        new_fig: boolean \
            Defines if the tree will be plotted \
            in the current figure (False) \
            or in a new figure (True) \
            Default value is True.
        subplot: matplotlib subplot value or False \
            If False the default subplot 111 will be used. \
            For any other value a matplotlib subplot \
            will be generated. \
            Default value is False.

    Returns:
        A 3D matplotlib figure with a soma view.
    """
    treecolor = kwargs.get("treecolor", None)

    # Initialization of matplotlib figure and axes.
    fig, ax = common.get_figure(new_fig=new_fig, new_axes=new_axes, subplot=subplot, params={"projection": "3d"})

    # Definition of the tree color depending on the tree type.
    treecolor = common.get_color(treecolor, tree_type=TreeType.soma)

    xs = sm.center[0]
    ys = sm.center[1]
    zs = sm.center[2]

    # Plot the soma as a circle.
    fig, ax = common.plot_sphere(
        fig, ax, center=[xs, ys, zs], radius=sm.radius, color=treecolor, alpha=get_default("alpha", **kwargs)
    )

    kwargs["title"] = kwargs.get("title", "Soma view")
    kwargs["xlabel"] = kwargs.get("xlabel", "X")
    kwargs["ylabel"] = kwargs.get("ylabel", "Y")
    kwargs["zlabel"] = kwargs.get("zlabel", "Z")

    return common.plot_style(fig=fig, ax=ax, **kwargs)
Beispiel #7
0
def test_plot_sphere():
    fig0, ax0 = get_figure(params={'projection': '3d'})
    fig1, ax1 = plot_sphere(fig0, ax0, [0, 0, 0], 10., color='black', alpha=1.)
    nt.ok_(ax1.has_data() == True)
Beispiel #8
0
def test_plot_sphere():
    fig0, ax0 = get_figure(params={'projection':'3d'})
    fig1, ax1 = plot_sphere(fig0, ax0, [0,0,0], 10., color='black', alpha=1.)
    nt.ok_(ax1.has_data() == True)
Beispiel #9
0
def test_plot_sphere():
    fig0, ax0 = get_figure(params={'projection': '3d'})
    plot_sphere(ax0, [0, 0, 0], 10., color='black', alpha=1.)
    assert ax0.has_data()