How to use the plotly.graph_objs 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 vaexio / vaex / packages / vaex-plotly / vaex / plotly / __init__.py View on Github external
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

        fig = go.FigureWidget(data=[dummy_scatter, heatmap], layout=layout)

        @_widget_progress_output.capture(clear_output=True)
        def _pan_and_zoom(layout, _xrange, _yrange):
            limits = [_yrange, _xrange]
            extent, counts = self._grid(expr=binby, what=what, shape=shape, limits=limits, f=_widget_f.v_model, progress=True)
            with fig.batch_update():
                fig.data[1]['z'] = counts
github keptenkurk / BS440 / plugins / BS440webapp / BS440plot.py View on Github external
meterValues.append(float(baseLabels[i+1]) - float(baseLabels[i]))
		meterSum += meterValues[i]

	meterValues[0] = meterSum

	# Dial path. Apply angle from full left position.
	rangeValue = float(meterValues[0])
	minValue=float(baseLabels[1])
	chartCenter=0.5
	dialTip=chartCenter-0.12
	dialAngle=(value-minValue)*180/rangeValue
	dialPath = 'M ' + rotatePoint((chartCenter,0.5),(chartCenter,0.485),dialAngle, 'dialPath') + ' L ' + rotatePoint((chartCenter,0.5),(dialTip,0.5),dialAngle, 'dialPath') + ' L ' + rotatePoint((chartCenter,0.5),(chartCenter,0.515),dialAngle, 'dialPath') + ' Z'
	infoText=(str(value) + str(suffix))

	# Gauge
	meterChart = go.Pie(
		values=meterValues, labels=meterLabels,
		marker=dict(colors=colors, 
			line=dict(width=0) # Switch line width to 0 in production
			),
		name="Gauge", hole=.3, direction="clockwise", rotation=90,
		showlegend=False, textinfo="label", textposition="inside", hoverinfo="none",
		sort=False
			)

	# Layout
	layout = go.Layout(
		xaxis=dict(showticklabels=False, autotick=False, showgrid=False, zeroline=False,),
		yaxis=dict(showticklabels=False, autotick=False, showgrid=False, zeroline=False,),
		shapes=[dict(
				type='path', path=dialPath, fillcolor='rgba(44, 160, 101, 1)',
				line=dict(width=0.5), xref='paper', yref='paper'),
github facebookresearch / craftassist / python / craftassist / voxel_models / plot_voxels.py View on Github external
return w
        else:
            maxid = max(clrs)
            clr_set = set(clrs)
            cmap = [
                [
                    c / maxid,
                    "rgb({},{},{})".format(
                        self.index_to_color[c][0],
                        self.index_to_color[c][1],
                        self.index_to_color[c][0],
                    ),
                ]
                for c in clr_set
            ]
            trace1 = go.Volume(
                x=np.asarray(x).transpose(),
                y=np.asarray(y).transpose(),
                z=np.asarray(z).transpose(),
                value=np.asarray(clrs).transpose(),
                isomin=0.1,
                isomax=0.8,
                colorscale=cmap,
                opacity=0.1,  # needs to be small to see through all surfaces
                surface_count=21,  # needs to be a large number for good volume rendering
            )
            data = [trace1]
            layout = go.Layout(margin=dict(l=0, r=0, b=0, t=0))
            fig = go.Figure(data=data, layout=layout)
            self.viz.plotlyplot(fig)
        return fig
github AntonelliLab / seqcap_processor / src / heatmap_plot.py View on Github external
#                   colorscale='Magma')]
#layout = go.Layout(
#    title='Average read coverage for all loci',
#    xaxis = dict(ticks='', nticks=len(x_axis)),
#    yaxis = dict(ticks='' ,nticks=int(len(y_axis)/10),autorange='reversed'),
#)
#figure = go.Figure(data=data, layout=layout)
#py.plot(figure)
#py.image.save_as(figure, format = 'pdf', filename='./tests/read_coverage_per_locus.pdf', width = 1080, height = 1000)
#help(py.image.save_as)


## 2. Alternative plot with reversed axes
trans_z_axis = np.transpose(z_axis)

data1 = go.Heatmap(z=trans_z_axis,
                   x=y_axis,
                   y=x_axis,
                   zmin = 1.0,
                   zmax = 20.0,
                   #colorscale='Viridis',
                   colorscale='Magma')
data = [data1]
lenx1 = len(x_axis)
leny1 = len(y_axis)

layout = go.Layout(
    title='Average read coverage for all loci',
    xaxis = dict(ticks='',nticks=int(len(y_axis)/20)),
    yaxis = dict(nticks=len(x_axis)),
)
figure1 = go.Figure(data=data, layout=layout)
github plotly / plotly.py / packages / python / plotly / plotly / express / _core.py View on Github external
def configure_axes(args, constructor, fig, orders):
    configurators = {
        go.Scatter: configure_cartesian_axes,
        go.Scattergl: configure_cartesian_axes,
        go.Bar: configure_cartesian_axes,
        go.Box: configure_cartesian_axes,
        go.Violin: configure_cartesian_axes,
        go.Histogram: configure_cartesian_axes,
        go.Histogram2dContour: configure_cartesian_axes,
        go.Histogram2d: configure_cartesian_axes,
        go.Scatter3d: configure_3d_axes,
        go.Scatterternary: configure_ternary_axes,
        go.Scatterpolar: configure_polar_axes,
        go.Scatterpolargl: configure_polar_axes,
        go.Barpolar: configure_polar_axes,
        go.Scattermapbox: configure_mapbox,
        go.Choroplethmapbox: configure_mapbox,
        go.Densitymapbox: configure_mapbox,
        go.Scattergeo: configure_geo,
        go.Choropleth: configure_geo,
    }
    if constructor in configurators:
        configurators[constructor](args, fig, orders)
github cdubz / babybuddy / reports / graphs / sleep_totals.py View on Github external
y=[td.seconds/3600 for td in totals.values()],
        hoverinfo='text',
        textposition='outside',
        text=[_duration_string_short(td) for td in totals.values()]
    )

    layout_args = utils.default_graph_layout_options()
    layout_args['barmode'] = 'stack'
    layout_args['title'] = _('<b>Sleep Totals</b>')
    layout_args['xaxis']['title'] = _('Date')
    layout_args['xaxis']['rangeselector'] = utils.rangeselector_date()
    layout_args['yaxis']['title'] = _('Hours of sleep')

    fig = go.Figure({
        'data': [trace],
        'layout': go.Layout(**layout_args)
    })
    output = plotly.plot(fig, output_type='div', include_plotlyjs=False)
    return utils.split_graph_output(output)
github jhwang1992 / network-visualization / app.py View on Github external
index = 0
    for node in G.nodes():
        x, y = G.nodes[node]['pos']
        hovertext = "CustomerName: " + str(G.nodes[node]['CustomerName']) + "<br>" + "AccountType: " + str(
            G.nodes[node]['Type'])
        text = node1['Account'][index]
        node_trace['x'] += tuple([x])
        node_trace['y'] += tuple([y])
        node_trace['hovertext'] += tuple([hovertext])
        node_trace['text'] += tuple([text])
        index = index + 1

    traceRecode.append(node_trace)
    ################################################################################################################################################################
    middle_hover_trace = go.Scatter(x=[], y=[], hovertext=[], mode='markers', hoverinfo="text",
                                    marker={'size': 20, 'color': 'LightSkyBlue'},
                                    opacity=0)

    index = 0
    for edge in G.edges:
        x0, y0 = G.nodes[edge[0]]['pos']
        x1, y1 = G.nodes[edge[1]]['pos']
        hovertext = "From: " + str(G.edges[edge]['Source']) + "<br>" + "To: " + str(
            G.edges[edge]['Target']) + "<br>" + "TransactionAmt: " + str(
            G.edges[edge]['TransactionAmt']) + "<br>" + "TransactionDate: " + str(G.edges[edge]['Date'])
        middle_hover_trace['x'] += tuple([(x0 + x1) / 2])
        middle_hover_trace['y'] += tuple([(y0 + y1) / 2])
        middle_hover_trace['hovertext'] += tuple([hovertext])
        index = index + 1

    traceRecode.append(middle_hover_trace)
github zvtvz / zvt / zvt / drawer / drawer.py View on Github external
def gen_plotly_layout(self,
                          width=None,
                          height=None,
                          title=None,
                          keep_ui_state=True,
                          subplot=False,
                          need_range_selector=True,
                          **layout_params):
        if keep_ui_state:
            uirevision = True
        else:
            uirevision = None

        layout = go.Layout(showlegend=True,
                           uirevision=uirevision,
                           height=height,
                           width=width,
                           title=title,
                           annotations=to_annotations(self.annotation_df),
                           yaxis=dict(
                               autorange=True,
                               fixedrange=False,
                               zeroline=False
                           ),
                           **layout_params)

        if subplot:
            layout.yaxis2 = dict(autorange=True,
                                 fixedrange=False,
                                 zeroline=False)
github DeFacto / DeFacto / python / trustworthiness / benchmark_script.py View on Github external
# Step size of the mesh. Decrease to increase the quality of the VQ.
    h = .02  # point in the mesh [x_min, x_max]x[y_min, y_max].

    # Plot the decision boundary. For that, we will assign a color to each
    x_min, x_max = reduced_data[:, 0].min() - 1, reduced_data[:, 0].max() + 1
    y_min, y_max = reduced_data[:, 1].min() - 1, reduced_data[:, 1].max() + 1
    print(x_min, x_max, y_min, y_max)
    xx, yy = np.meshgrid(np.arange(x_min, x_max, h), np.arange(y_min, y_max, h))

    # Obtain labels for each point in mesh. Use last trained model.
    Z = kmeans.predict(np.c_[xx.ravel(), yy.ravel()])

    # Put the result into a color plot
    Z = Z.reshape(xx.shape)

    back = go.Heatmap(x=xx[0][:len(Z)],
                      y=xx[0][:len(Z)],
                      z=Z,
                      showscale=False,
                      colorscale=matplotlib_to_plotly(plt.cm.Paired, len(Z)))

    markers = go.Scatter(x=reduced_data[:, 0],
                         y=reduced_data[:, 1],
                         showlegend=False,
                         mode='markers',
                         marker=dict(
                             size=3, color='black'))

    # Plot the centroids as a white
    centroids = kmeans.cluster_centers_
    center = go.Scatter(x=centroids[:, 0],
                        y=centroids[:, 1],
github racinmat / anime-style-transfer / code / autoencoders / dimension_reduction_eval.py View on Github external
continue
        dimension = {
            'label': col_name,
        }

        if isinstance(column.dtype, pd.CategoricalDtype):
            dimension['range'] = [df[col_name + '_encoded'].min(), df[col_name + '_encoded'].max()]
            dimension['values'] = df[col_name + '_encoded'].values
            dimension['tickvals'] = np.unique(column.cat.codes)
            dimension['ticktext'] = column.cat.categories.values
        else:
            dimension['range'] = [column.min(), column.max()]
            dimension['values'] = column.values
        dimensions.append(dimension)
    data = [
        go.Parcoords(
            line=dict(color='blue'),
            # dimensions=list([
            #     dict(range=[1, 5],
            #          constraintrange=[1, 2],
            #          label='A', values=[1, 4]),
            #     dict(range=[1.5, 5],
            #          tickvals=[1.5, 3, 4.5],
            #          label='B', values=[3, 1.5]),
            #     dict(range=[1, 5],
            #          tickvals=[1, 2, 4, 5],
            #          label='C', values=[2, 4],
            #          ticktext=['text 1', 'text 2', 'text 3', 'text 4']),
            #     dict(range=[1, 5],
            #          label='D', values=[4, 2])
            # ]),
            dimensions=dimensions,