How to use the plotly.graph_objs.Heatmap function in plotly

To help you get started, we’ve selected a few plotly examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github DeniseCaiLab / minian / minian / visualization_ply.py View on Github external
def _update_spatial_unit(self, uid, rely1, rely2, rely3, rely4, rely5,
                             state):
        print('update_spatial_unit')
        _initial = False
        _update = False
        if not state:
            _initial = True
        elif not state['data'][0]['customdata'] == uid:
            _update = True
        if _initial or _update:
            cur_A = self.cnmf['A'].sel(unit_id=uid if not uid is None else [])
            trace = [
                go.Heatmap(
                    x=cur_A.coords['width'].values,
                    y=cur_A.coords['height'].values,
                    z=cur_A.values,
                    colorscale='Viridis',
                    colorbar=dict(x=1),
                    hoverinfo='none',
                    customdata=uid)
            ]
            if _update:
                state.update(data=trace)
        if _initial:
            layout = go.Layout(
                title="Spatial Component of unit: {}".format(uid),
                xaxis=dict(
                    title='width',
                    range=[0, self._w],
github flask-dashboard / Flask-MonitoringDashboard / flask_monitoringdashboard / routings / measurements.py View on Github external
data_list[i].append(data[all_endpoints[i]][versions[j]])

    layout = go.Layout(
        autosize=True,
        height=800,
        plot_bgcolor='rgba(249,249,249,1)',
        showlegend=False,
        title='Heatmap of hits per endpoint per version',
        xaxis=go.XAxis(title='Versions', type='category'),
        yaxis=dict(type='category', autorange='reversed'),
        margin=go.Margin(
            l=200
        )
    )

    trace = go.Heatmap(
        z=data_list,
        x=versions,
        y=all_endpoints,
        colorscale=[[0, 'rgb(255, 255, 255)'], [0.01, 'rgb(240,240,240)'],[1, 'rgb(1, 1, 1)']],
        colorbar=dict(
            titleside='top',
            tickmode='array',
            tickvals=[1, 0],
            ticktext=['100%', '0%'],
            # ticks='outside'
        )
    )
    return plotly.offline.plot(go.Figure(data=[trace], layout=layout), output_type='div', show_link=False)
github andreiapostoae / dota2-predictor / visualizing / hero_combinations.py View on Github external
synergies = np.loadtxt('pretrained/synergies_all.csv')

    for i in range(114):
        synergies[i, i] = 0.5

    hero_dict = get_hero_dict()

    x_labels = []
    for i in range(114):
        if i != 23:
            x_labels.append(hero_dict[i + 1])

    synergies = np.delete(synergies, [23], 0)
    synergies = np.delete(synergies, [23], 1)

    trace = go.Heatmap(z=synergies,
                       x=x_labels,
                       y=x_labels,
                       colorscale='Viridis')

    layout = go.Layout(
        title='Hero synergies',
        width=1000,
        height=1000,
        xaxis=dict(ticks='',
                   nticks=114,
                   tickfont=dict(
                        size=8,
                        color='black')),
        yaxis=dict(ticks='',
                   nticks=114,
                   tickfont=dict(
github SPFlow / SPFlow / src / deep_notebooks / dn_plot.py View on Github external
x_range = np.linspace(spn.domains[featureId][0], spn.domains[featureId][-1], detail)
    query = np.repeat(evidence, x_range.shape[0], axis=0)
    query[:,featureId] = x_range
    y_range = np.exp(marg_spn.eval(query))

    plt.plot(x_range, y_range)
    plt.ylim(ymin=0)
    plt.ylim(ymax=np.amax(y_range) + 1)
    Scatter(
        x = random_x,
        y = random_y0,
        mode = 'lines',
        name = 'lines'
    )
    data = [Heatmap(z=result,
            y=np.linspace(spn.domains[featureId_y][0], spn.domains[featureId_y][-1], detail) if not y_cat else y_names,
            x=np.linspace(spn.domains[featureId_x][0], spn.domains[featureId_x][-1], detail) if not x_cat else x_names,
            colorbar=ColorBar(
                title='Colorbar'
            ),
            colorscale='Hot')]
    layout = dict(width=450, 
                  height=450,
                  xaxis=dict(title=spn.featureNames[featureId_y]),
                  yaxis=dict(title=spn.featureNames[featureId_x])
                 )

    if fname is None:
        return {'data': data, 'layout': layout}
    else:
        raise NotImplementedError
github vaexio / vaex / packages / vaex-plotly / vaex / plotly / __init__.py View on Github external
#  Creating the plotly figure, which is also a widget
        x = _ensure_string_from_expression(x)
        y = _ensure_string_from_expression(y)

        binby = []
        for expression in [y, x]:
            if expression is not None:
                binby = [expression] + binby
        limits = self.df.limits(binby, limits)

        extent, counts = self._grid(expr=binby, what=what, shape=shape, limits=limits,
                                    f=_widget_f.v_model, n=n, selection=selection, progress=progress)

        cbar = go.heatmap.ColorBar(title=colorbar_label)
        heatmap = go.Heatmap(z=counts, colorscale=colormap, zmin=vmin, zmax=vmax,
                             x0=extent[0], dx=np.abs((extent[1]-extent[0])/shape),
                             y0=extent[2], dy=np.abs((extent[3]-extent[2])/shape),
                             colorbar=cbar, showscale=colorbar,
                             hoverinfo=['x', 'y', 'z'])

        dummy_scatter = go.Scatter(y=[None])

        title = go.layout.Title(text=title, xanchor='center', x=0.5, yanchor='top')
        layout = go.Layout(height=figure_height,
                           width=figure_width,
                           title=title,
                           xaxis=go.layout.XAxis(title='x', range=limits[0]),
                           yaxis=go.layout.YAxis(title='y', range=limits[1], scaleanchor='x', scaleratio=1))
        if equal_aspect:
            layout['yaxis']['scaleanchor'] = 'x'
            layout['yaxis']['scaleratio'] = 1
github MaayanLab / FAIRshake / FAIRshakeAPI / stats.py View on Github external
objs = [
    obj.title
    for obj in project.digital_objects.all()
  ]
  scores = [
    [
      np.mean([
        answer.value()
        for answer in models.Answer.objects.filter(metric=metric, assessment__target=obj)
      ])
      for assessment in obj.assessments.all()
      for metric in assessment.rubric.metrics.all()
    ]
    for obj in project.digital_objects.all()
  ]
  trace = go.Heatmap(z=scores, x=metrics, y=objs)
  data = [trace]
  layout = go.Layout(xaxis=dict(title="Metrics",ticks='',
        showticklabels=False, automargin=True),yaxis=dict(title='Digital Objects',ticks='',
        showticklabels=True, automargin=True))
  fig = go.Figure(data=data, layout=layout)
  yield _iplot(fig)
github DeniseCaiLab / minian / minian / visualization_ply.py View on Github external
def _update_movies_res(self, sig_mov, rely1, rely2, rely3, rely4, rely5,
                           state):
        print('update movie res')
        sig_mov = json.loads(sig_mov)
        _initial = False
        _update = False
        if state:
            if not state['data'][0]['customdata'] == sig_mov['f']:
                _update = True
        else:
            _initial = True
        if _initial or _update:
            print("updating res trace")
            trace = [
                go.Heatmap(
                    x=self.cur_res.coords['width'].values,
                    y=self.cur_res.coords['height'].values,
                    z=self.cur_res.values,
                    colorscale='Viridis',
                    colorbar=dict(x=1),
                    customdata=sig_mov,
                    hoverinfo='none')
            ]
            if _update:
                state.update(data=trace)
        if _initial:
            layout = go.Layout(
                title="Residual at frame: {}".format(sig_mov['f']),
                xaxis=dict(
                    title='width',
                    range=[0, self._w],
github hrpan / tetris_mcts / web / web_dash.py View on Github external
'font': {'color': colors['text']}},
        plot_bgcolor=colors['background'],
        paper_bgcolor=colors['background'],
        font={'color': colors['text']},
        xaxis={'rangemode': 'tozero'},
        yaxis={'rangemode': 'tozero'},
        uirevision=True
    )
)

colorscale = [[0, 'rgb(100, 100, 100)'],
              [0.5, 'rgb(0, 0, 0)'],
              [1, 'rgb(255, 255, 255)']]
fig_board = go.Figure(
    data=[
        go.Heatmap(z=[[0] * 10] * 20, hoverinfo='none',
                   colorscale=colorscale, showscale=False,
                   xgap=1, ygap=1)
    ],
    layout=go.Layout(
        plot_bgcolor=colors['background'],
        paper_bgcolor=colors['background'],
        font={'color': colors['text']},
        height=700,
        width=300,
        xaxis=dict(visible=False),
        yaxis=dict(visible=False),
        margin=dict(l=5, t=5, b=5, r=5),
        hovermode=False
    ),
)
github rsemeraro / PyPore / lib / seq_routines.py View on Github external
[0.6666666666666666, 'rgb(199,234,229)'], [0.7777777777777778, 'rgb(128,205,193)'],
                     [0.8888888888888888, 'rgb(53,151,143)'], [1.0, 'rgb(1,102,94)']]

    xh = map(list, zip(*NanoLayout))
    yh = map(list, zip(*NanoPlate))
    zh = map(list, zip(*NanoBasePlate))
    hovertext=[[] for i in range(len(xh))]

    for x1, y1 in enumerate(xh):
        for x2, y2 in enumerate(y1):
            hovertext[x1].append('<b>CHANNEL:</b> {}<br><b>RN:</b> {}<br><b>BN:</b> {}'.format(y2, yh[x1][x2], zh[x1][x2]))

    trace = go.Heatmap(name="ReadNHeat", z=map(list, zip(*NanoPlate)), x=range(1, 33), y=range(1, 17),
                       text=hovertext, hoverinfo="text", xgap=23, ygap=8, colorscale=owncolorscale,
                       colorbar=dict(y=0.77, len=0.470, exponentformat="SI"))  # y=0.77,
    trace1 = go.Heatmap(name="BaseNHeat", z=map(list, zip(*NanoBasePlate)), x=range(1, 33), y=range(1, 17),
                        text=hovertext, hoverinfo="text", xgap=23, ygap=8, colorscale=owncolorscale,
                        colorbar=dict(y=0.77, len=0.470, exponentformat="SI"), visible=False)
    fig = plotly.tools.make_subplots(rows=13, cols=1, shared_xaxes=False,
                                     specs=[[{'rowspan': 6}], [None], [None], [None], [None], [None], [None],
                                            [{'rowspan': 2}], [None], [{'rowspan': 2}], [None], [None],
                                            [{'rowspan': 1}]],
                                     vertical_spacing=0.001, print_grid=False)

    log.debug("Heatmaps ready!")

    VisibleData = [False] * (513 * 10)

    updatemenus = list([
        dict(type="buttons",
             active=-1,
             buttons=list([
github tyiannak / multimodalAnalysis / audio / example06.py View on Github external
yaxis=dict(title='Mel Coefficient (index)',))

def normalize_signal(signal):
    signal = np.double(signal)
    signal = signal / (2.0 ** 15)
    return (signal - signal.mean()) / ((np.abs(signal)).max() + 0.0000000001)

if __name__ == '__main__':
    [Fs, s] = wavfile.read("../data/sample_music.wav")
    s = normalize_signal(s)
    S = librosa.feature.melspectrogram(s, Fs, None, int(Fs * 0.020),
                                       int(Fs * 0.020), power=2)
    # create frequency and time axes
    f = list(range(S.shape[0]))
    t = [float(t * int(Fs * 0.020)) / Fs for t in range(S.shape[1])]
    heatmap = go.Heatmap(z=S, y=f, x=t)
    plotly.offline.plot(go.Figure(data=[heatmap], layout=layout),
                        filename="temp.html", auto_open=True)