Python plotly.graph_objs 模块,Scattergl() 实例源码

我们从Python开源项目中,提取了以下5个代码示例,用于说明如何使用plotly.graph_objs.Scattergl()

项目:kindel    作者:bede    | 项目源码 | 文件源码
def plotly_samtools_depth(ids_depths):
    n_positions = len(ids_depths[max(ids_depths, key=lambda x: len(set(ids_depths[x])))])
    traces = []
    for id, depths in sorted(ids_depths.items()):
        traces.append(
            go.Scattergl(
                x=list(range(1, n_positions)),
                y=depths,
                mode='lines',
                name=id,
                text=id))
    layout = go.Layout(
        title='Depth of coverage',
        xaxis=dict(
            title='Position',
            gridcolor='rgb(255, 255, 255)',
            gridwidth=2),
        yaxis=dict(
            title='Depth',
            gridcolor='rgb(255, 255, 255)',
            gridwidth=2,
            type='log'),
        paper_bgcolor='rgb(243, 243, 243)',
        plot_bgcolor='rgb(243, 243, 243)')

    fig = go.Figure(data=traces, layout=layout)
    py.plot(fig, filename='depths.html')
项目:kindel    作者:bede    | 项目源码 | 文件源码
def plotly_variants(ids_data):
    import plotly.offline as py
    import plotly.graph_objs as go
    traces = []
    for id, data in sorted(ids_data.items()):
        traces.append(
            go.Scattergl(
                x=data['pos'],
                y=data['max_alt'],
                mode='markers',
                name=id,
                text=id))
    layout = go.Layout(
        title='Variants',
        xaxis=dict(
            title='Position',
            gridcolor='rgb(255, 255, 255)',
            gridwidth=2),
        yaxis=dict(
            title='Abundance',
            gridcolor='rgb(255, 255, 255)',
            gridwidth=2,
            type='linear'),
        paper_bgcolor='rgb(243, 243, 243)',
        plot_bgcolor='rgb(243, 243, 243)')

    fig = go.Figure(data=traces, layout=layout)
    py.plot(fig, filename='variants.html')
项目:tRECS    作者:TeeOhh    | 项目源码 | 文件源码
def update_graph(threshold):
    # '''
    #   Description: Updates the threshold graph with only the words that are between the two user selected thersholds from the dash slider.
    #   Params: Threshold tuple (lower threshold, upper threshold)
    #   Returns: Graph data for only the words and word frequencies of the words between the two thresholds.
    # '''

    global interface_obj
    ## Get bottom & top thresholds and rebuild the word/doc. freq. dataframe
    bottom_threshold = float(threshold[0]) * float(5) / float(100) * float(len(interface_obj.clean_df))
    top_threshold = float(threshold[1]) * float(5) / float(100) * float(len(interface_obj.clean_df))
    new_df1 = interface_obj.freq_matrix.where(interface_obj.freq_matrix[1] >= bottom_threshold).dropna()
    new_df2 = interface_obj.freq_matrix.where(interface_obj.freq_matrix[1] <= top_threshold).dropna()

    ## Merge on words above bottom thresh. and words below top thresh.
    interface_obj.freq_matrix_keep = pd.merge(new_df1, new_df2, how='inner', on=[0])

    return {
        ## Set x as doc. freq. of words within bottom and top thresholds
        'data' : [graph.Scattergl(
        x = interface_obj.freq_matrix_keep['1_y'],
        y = interface_obj.freq_matrix_keep.index,
        mode = 'markers',
        text = interface_obj.freq_matrix_keep[0]
        )],
        ## Rebuild range of x and y axis with min and max of new dataframe
        'layout' : graph.Layout(
        xaxis = {'title' : 'Document Frequency'},
        yaxis = {'title' : 'Word Ids (ordered by doc. freq.)'},
        hovermode = 'closest',
    )
}
项目:kindel    作者:bede    | 项目源码 | 文件源码
def plotly_clips(bam_path):
    import plotly.offline as py
    import plotly.graph_objs as go
    aln = list(parse_bam(bam_path).items())[0][1]
    aligned_depth = [sum(weight.values()) for weight in aln.weights]
    ins = [sum(i.values()) for i in aln.insertions]
    x_axis = list(range(len(aligned_depth)))
    traces = [
        go.Scattergl(
            x = x_axis,
            y = aligned_depth,
            mode = 'lines',
            name = 'Aligned depth'),
        go.Scattergl(
            x = x_axis,
            y = aln.consensus_depth,
            mode = 'lines',
            name = 'Consensus depth'),
        go.Scattergl(
            x = x_axis,
            y = aln.clip_start_depth,
            mode = 'lines',
            name = 'Soft clip start depth'),
        go.Scattergl(
            x = x_axis,
            y = aln.clip_end_depth,
            mode = 'lines',
            name = 'Soft clip end depth'),
        go.Scattergl(
            x = x_axis,
            y = aln.clip_starts,
            mode = 'markers',
            name = 'Soft clip starts'),
        go.Scattergl(
            x = x_axis,
            y = aln.clip_ends,
            mode = 'markers',
            name = 'Soft clip ends'),
        go.Scattergl(
            x = x_axis,
            y = ins,
            mode = 'markers',
            name = 'Insertions'),
        go.Scattergl(
            x = x_axis,
            y = aln.deletions,
            mode = 'markers',
            name = 'Deletions')]
    layout = go.Layout(
        xaxis=dict(
            type='linear',
            autorange=True),
        yaxis=dict(
            type='linear',
            autorange=True))
    fig = go.Figure(data=traces, layout=layout)
    out_fn = os.path.splitext(os.path.split(bam_path)[1])[0]
    py.plot(fig, filename=out_fn + '.clips.html')
项目:policosm    作者:ComplexCity    | 项目源码 | 文件源码
def plotRoadsGraph(graph):
    data = []
    for u,v in graph.edges():
        data.append(
            go.Scattergl(
                x = [graph.node[u]['longitude'], graph.node[v]['longitude']],
                y = [graph.node[u]['latitude'], graph.node[v]['latitude']],
                mode = 'lines',
                line = my_style[graph[u][v]['level']],
                )
            )

    x,y = getCentroidFromRoadsGraph(graph)
    boundaries = getBoundaries(graph)
    width = boundaries[2]-boundaries[0]
    height = boundaries[3]-boundaries[1]
    standard = max([width,height])
    standard += standard * 0.1

    layout = go.Layout(
        showlegend=False,
        xaxis=dict(
            range=[x-standard/2, x+standard/2],
            showgrid=True,
            zeroline=False,
            showline=False,
            gridcolor='#eeeeee',
            gridwidth=1,
            linecolor='#eeeeee',
            linewidth=1
        ),
        yaxis=dict(
            range=[y-standard/2, y+standard/2],
            showgrid=True,
            zeroline=False,
            showline=False,
            gridcolor='#eeeeee',
            gridwidth=1,
            linecolor='#eeeeee',
            linewidth=1
        ),
        width=1000,
        height=1000 
    )

    return dict(data=data, layout=layout)