How to use the plotly.graph_objs.Figure 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 lucasrodes / whatstk / tests / graph / test_figures.py View on Github external
def test_user_interventions_count_linechart():
    df = load_chat_as_df()
    fb = FigureBuilder(df=df)
    fig = fb.user_interventions_count_linechart()
    assert isinstance(fig, go.Figure)
    assert ('data' in fig and 'layout' in fig)
github asrhou / scMatch / visAnnos.py View on Github external
size=5,
                    symbol='circle',
                    line=dict(
                        color='rgb(204, 204, 204)',
                        width=1
                    ),
                    opacity=0.9
                ),
                text = text,
             )
            data.append(trace)
        if annoLen < 35:
            layout = go.Layout(legend=dict(orientation="v"),autosize=True,showlegend=True)
        else:
            layout = go.Layout(legend=dict(orientation="v"),autosize=True,showlegend=False)
        fig = go.Figure(data=data, layout=layout)
        fn = os.path.join(savefolder, '%s_%s_%s.html' % (annText, kind.replace(' ', '_'), visMethod))
        print('##########saving plot: %s' % fn)
        plotly.offline.plot(fig, filename=fn)
github NationalSecurityAgency / timely / client / src / main / python / timely / DataOperations.py View on Github external
if data is None:
                data = [s]
            else:
                data.append(s)

        directory = analyticConfig.output_dir
        try:
            os.makedirs(directory, mode=0755)
        except OSError, e:
            # be happy if someone already created the path
            pass
        baseFilename = getFilename(timelyMetric.metric, analyticConfig)
        filename = directory+'/'+baseFilename

        fig = go.Figure(data=data, layout=layout)
        if notebook:
            py.iplot(fig, filename=filename, show_link=False)
            return None
        else:
            py.plot(fig, output_type='file', filename=filename+'.html', image_filename=filename, image=None, auto_open=False, show_link=False)
            return baseFilename+'.html'
github fgr1986 / rram_multilevel_driver / python_pre_study / aux_resistance.py View on Github external
color='#7f7f7f'
            )
        ),
        yaxis=dict(
            type='linear',
            autorange=True,
            title='Load Resistance [ohm]',
            titlefont=dict(
                family='Courier New, monospace',
                size=18,
                color='#7f7f7f'
            )
        )
    )

    fig = plotly.graph_objs.Figure(data=data_r_loads, layout=layout_r_loads)
    plotly.offline.plot(fig, filename = 'load_resistance.html')


# In[15]:


# v_gate
plot_v_gate = True

if plot_v_gate:
    aux_x = np.linspace(0, 2*v_set, 200)
    a=100
    aux_y = 1/(1+np.exp(a*(aux_x-v_set)))
    data_v_gate = [
        plotly.graph_objs.Scatter(
            x=aux_x,
github kellieotto / pscore_match / pscore_match / match.py View on Github external
shapes=[dict(
                type='line',
                x0=0.05,
                x1=0.05,
                y0=-1,
                y1=len(covnames),
                line=dict(
                    color='gray',
                    dash='dot'
                ),
            )],
            width=800,
            height=600,
            hovermode='closest'
        )
        fig = go.Figure(data=data, layout=layout)
        if notebook:
            plotly.offline.iplot(fig, filename=filename, show_link=False, **kwargs)
        else:
            plotly.offline.plot(fig, filename=filename, show_link=False, **kwargs)
github facebook / prophet / python / fbprophet / plot.py View on Github external
in the figure, if available.
    figsize: The plot's size (in px).

    Returns
    -------
    A Plotly Figure.
    """
    props = get_forecast_component_plotly_props(m, fcst, name, uncertainty, plot_cap)
    layout = go.Layout(
        width=figsize[0],
        height=figsize[1],
        showlegend=False,
        xaxis=props['xaxis'],
        yaxis=props['yaxis']
    )
    fig = go.Figure(data=props['traces'], layout=layout)
    return fig
github pailabteam / pailab / pailab / analysis / plot.py View on Github external
if ice_result.labels[i] in clusters:
                        ice_points_tmp.append(i)
                _ice_plotly(ice_result, ice_points=ice_points_tmp,
                            ice_results_2=ice_results_2, height=height, width=width)
            # plot ice curves
            for i in ice_points:
                data.append(go.Scatter(
                    x=ice_result.x_values, y=ice_result.ice[i, :], name=ice_result.data_name + '[' + str(ice_result.start_index + i) + ',:]'))
    layout = go.Layout(
        title=title,
        xaxis=dict(title=x_coord_name),
        yaxis=dict(title=y_coord_name),
        height=height,
        width=width
    )
    fig = go.Figure(data=data, layout=layout)
    if use_within_widget:
        return fig
    iplot(fig)  # , filename='pandas/basic-line-plot')
github TheIoTLearningInitiative / internetofthings101 / code / iotpy / projects / randomizer.py View on Github external
def graph(self):

        stream_randomizer = Scatter(
            x=[],
            y=[],
            stream=dict(
                token=self.streamtoken,
            )
        )

        layout = Layout(
            title="IoTPy Randomizer"
        )

        this = Figure(data=[stream_randomizer], layout=layout)
        py.plot(this, filename='IotPy Randomizer', auto_open=False)

        stream = py.Stream(self.streamtoken)
        stream.open()
        time.sleep(5)

        counter = 0

        while True:
            randomizerdata = randint(0,100)
            stream.write({'x': counter, 'y': randomizerdata})
            counter += 1
            time.sleep(0.25)
github zvtvz / zvt / zvt / drawer / dcc_components.py View on Github external
if pd_is_not_null(security_factor.data_df):
        print(security_factor.data_df.tail())

    # generate the annotation df
    order_reader.move_on(timeout=0)
    df = order_reader.data_df.copy()
    if pd_is_not_null(df):
        df['value'] = df['order_price']
        df['flag'] = df['order_type'].apply(lambda x: order_type_flag(x))
        df['color'] = df['order_type'].apply(lambda x: order_type_color(x))
    print(df.tail())

    data, layout = security_factor.draw(render=None, figures=go.Candlestick, annotation_df=df)

    return go.Figure(data=data, layout=layout)
github Parsl / parsl / parsl / monitoring / web_app / plots / default / memory_usage.py View on Github external
for app, tasks in apps_dict.items():
                tmp = []
                if option == 'avg':
                    task = df_resources[df_resources['task_id'] == app]['psutil_process_memory_resident'].astype('float').mean()
                elif option == 'max':
                    task = max(df_resources[df_resources['task_id'] == app]['psutil_process_memory_resident'].astype('float'))

                for i in range(len(x_axis) - 1):
                    a = task >= x_axis[i]
                    b = task < x_axis[i + 1]
                    tmp.append(a & b)
                items = np.sum([items, tmp], axis=0)
            return items

        return go.Figure(
            data=[go.Bar(x=[num / 1000000000 for num in x_axis[:-1]],
                         y=y_axis_setup(),
                         name='tasks')],
            layout=go.Layout(xaxis=dict(autorange=True,
                                        title='Usage (GB)'),
                             yaxis=dict(title='Tasks'),
                             title='Resident Memory Distribution'))