def get_figure(neuron, plane, title):
    '''Returns the plotly figure containing the neuron'''
    data = list(_make_trace(neuron, plane))
    axis = dict(
        gridcolor='rgb(255, 255, 255)',
        zerolinecolor='rgb(255, 255, 255)',
        showbackground=True,
        backgroundcolor='rgb(230, 230,230)'
    )

    if plane != '3d':
        soma_2d = [
            # filled circle
            {
                'type': 'circle',
                'xref': 'x',
                'yref': 'y',
                'fillcolor': 'rgba(50, 171, 96, 0.7)',
                'x0': neuron.soma.center[0] - neuron.soma.radius,
                'y0': neuron.soma.center[1] - neuron.soma.radius,
                'x1': neuron.soma.center[0] + neuron.soma.radius,
                'y1': neuron.soma.center[1] + neuron.soma.radius,

                'line': {
                    'color': 'rgba(50, 171, 96, 1)',
                },
            },
        ]

    else:
        soma_2d = []
        theta = np.linspace(0, 2 * np.pi, 100)
        phi = np.linspace(0, np.pi, 100)
        z = np.outer(np.ones(100), np.cos(phi)) + neuron.soma.center[2]
        r = neuron.soma.radius
        data.append(
            go.Surface(
                x=(np.outer(np.cos(theta), np.sin(phi)) + neuron.soma.center[0]) * r,
                y=(np.outer(np.sin(theta), np.sin(phi)) + neuron.soma.center[1]) * r,
                z=z * r,
                cauto=False,
                surfacecolor=['black'] * len(z),
                showscale=False,
            )
        )

    layout = dict(
        autosize=True,
        title=title,
        scene=dict(  # This is used for 3D plots
            xaxis=axis, yaxis=axis, zaxis=axis,
            camera=dict(up=dict(x=0, y=0, z=1), eye=dict(x=-1.7428, y=1.0707, z=0.7100,)),
            aspectmode='data'
        ),
        yaxis=dict(scaleanchor="x"),  # This is used for 2D plots
        shapes=soma_2d,
    )

    res = dict(data=data, layout=layout)
    return res
def get_figure ( neuron , plane , title ) : data = list ( _make_trace ( neuron , plane ) ) axis = dict ( gridcolor = 'rgb(255, 255, 255)' , zerolinecolor = 'rgb(255, 255, 255)' , showbackground = True , backgroundcolor = 'rgb(230, 230,230)' ) if plane != '3d' : soma_2d = [ { 'type' : 'circle' , 'xref' : 'x' , 'yref' : 'y' , 'fillcolor' : 'rgba(50, 171, 96, 0.7)' , 'x0' : neuron . soma . center [ 0 ] - neuron . soma . radius , 'y0' : neuron . soma . center [ 1 ] - neuron . soma . radius , 'x1' : neuron . soma . center [ 0 ] + neuron . soma . radius , 'y1' : neuron . soma . center [ 1 ] + neuron . soma . radius , 'line' : { 'color' : 'rgba(50, 171, 96, 1)' , } , } , ] else : soma_2d = [ ] theta = np . linspace ( 0 , 2 * np . pi , 100 ) phi = np . linspace ( 0 , np . pi , 100 ) z = np . outer ( np . ones ( 100 ) , np . cos ( phi ) ) + neuron . soma . center [ 2 ] r = neuron . soma . radius data . append ( go . Surface ( x = ( np . outer ( np . cos ( theta ) , np . sin ( phi ) ) + neuron . soma . center [ 0 ] ) * r , y = ( np . outer ( np . sin ( theta ) , np . sin ( phi ) ) + neuron . soma . center [ 1 ] ) * r , z = z * r , cauto = False , surfacecolor = [ 'black' ] * len ( z ) , showscale = False , ) ) layout = dict ( autosize = True , title = title , scene = dict ( xaxis = axis , yaxis = axis , zaxis = axis , camera = dict ( up = dict ( x = 0 , y = 0 , z = 1 ) , eye = dict ( x = - 1.7428 , y = 1.0707 , z = 0.7100 , ) ) , aspectmode = 'data' ) , yaxis = dict ( scaleanchor = "x" ) , shapes = soma_2d , ) res = dict ( data = data , layout = layout ) return res
Returns the plotly figure containing the neuron