当前位置: 首页>>代码示例>>Python>>正文


Python offline.plot方法代码示例

本文整理汇总了Python中plotly.offline.plot方法的典型用法代码示例。如果您正苦于以下问题:Python offline.plot方法的具体用法?Python offline.plot怎么用?Python offline.plot使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在plotly.offline的用法示例。


在下文中一共展示了offline.plot方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: observation_plan

# 需要导入模块: from plotly import offline [as 别名]
# 或者: from plotly.offline import plot [as 别名]
def observation_plan(target, facility, length=7, interval=60, airmass_limit=None):
    """
    Displays form and renders plot for visibility calculation. Using this templatetag to render a plot requires that
    the context of the parent view have values for start_time, end_time, and airmass.
    """

    visibility_graph = ''
    start_time = datetime.now()
    end_time = start_time + timedelta(days=length)

    visibility_data = get_sidereal_visibility(target, start_time, end_time, interval, airmass_limit)
    plot_data = [
        go.Scatter(x=data[0], y=data[1], mode='lines', name=site) for site, data in visibility_data.items()
    ]
    layout = go.Layout(yaxis=dict(autorange='reversed'))
    visibility_graph = offline.plot(
        go.Figure(data=plot_data, layout=layout), output_type='div', show_link=False
    )

    return {
        'visibility_graph': visibility_graph
    } 
开发者ID:TOMToolkit,项目名称:tom_base,代码行数:24,代码来源:observation_extras.py

示例2: _draw_scatter

# 需要导入模块: from plotly import offline [as 别名]
# 或者: from plotly.offline import plot [as 别名]
def _draw_scatter(all_vocabs, all_freqs, output_prefix):
    colors = [(s and t) and (s < t and s / t or t / s) or 0
              for s, t in all_freqs]
    colors = [c and np.log(c) or 0 for c in colors]
    trace = go.Scattergl(
        x=[s for s, t in all_freqs],
        y=[t for s, t in all_freqs],
        mode='markers',
        text=all_vocabs,
        marker=dict(color=colors, showscale=True, colorscale='Viridis'))
    layout = go.Layout(
        title='Scatter plot of shared tokens',
        hovermode='closest',
        xaxis=dict(title='src freq', type='log', autorange=True),
        yaxis=dict(title='trg freq', type='log', autorange=True))

    fig = go.Figure(data=[trace], layout=layout)
    py.plot(
        fig, filename='{}_scatter.html'.format(output_prefix), auto_open=False) 
开发者ID:vincentzlt,项目名称:textprep,代码行数:21,代码来源:draw.py

示例3: __init__

# 需要导入模块: from plotly import offline [as 别名]
# 或者: from plotly.offline import plot [as 别名]
def __init__(self, contents, plotly_kwargs=None, **kwargs):
        """
        Writes out the content as raw text or HTML.

        :param contents: Plotly graphics object figure.
        :param plotly_kwargs: Kwargs that are passed to plotly plot function.
        :param kwargs: Optional styling arguments. The `style` keyword argument has special
                       meaning in that it allows styling to be grouped as one argument.
                       It is also useful in case a styling parameter name clashes with a standard
                       block parameter.
        """
        self.resource_deps = [JScript(script_string=po.offline.get_plotlyjs(), name='plotly')]

        super(PlotlyPlotBlock, self).__init__(**kwargs)

        if not isinstance(contents, PlotlyFigure):
            raise ValueError("Expected plotly.graph_objs.graph_objs.Figure type but got %s", type(contents))

        plotly_kwargs = plotly_kwargs or {}
        prefix = "<script>if (typeof require !== 'undefined') {var Plotly=require('plotly')}</script>"
        self._contents = prefix + po.plot(contents, include_plotlyjs=False, output_type='div', **plotly_kwargs) 
开发者ID:man-group,项目名称:PyBloqs,代码行数:23,代码来源:image.py

示例4: calc_graph

# 需要导入模块: from plotly import offline [as 别名]
# 或者: from plotly.offline import plot [as 别名]
def calc_graph(self):
        # calculate graph
        graph = []
        # format demand values
        P_loss_kWh = self.P_loss_kWh.fillna(value=0)
        P_loss_kWh = pd.DataFrame(P_loss_kWh.sum(axis=0), columns=['P_loss_kWh'])
        Q_loss_kWh = abs(self.thermal_loss_edges_kWh.fillna(value=0))
        Q_loss_kWh = pd.DataFrame(Q_loss_kWh.sum(axis=0), columns=['Q_loss_kWh'])
        # calculate total_df
        total_df = pd.DataFrame(P_loss_kWh.values + Q_loss_kWh.values, index=Q_loss_kWh.index, columns=['total'])
        # join dataframes
        merged_df = P_loss_kWh.join(Q_loss_kWh).join(total_df)
        merged_df = merged_df.sort_values(by='total',
                                          ascending=False)  # this will get the maximum value to the left

        # iterate through P_loss_kWh to plot
        for field in ['P_loss_kWh', 'Q_loss_kWh']:
            total_percent = (merged_df[field] / merged_df['total'] * 100).round(2)
            total_percent_txt = ["(" + str(x) + " %)" for x in total_percent]
            trace = go.Bar(x=merged_df.index, y=merged_df[field].values, name=NAMING[field],
                           text=total_percent_txt,
                           orientation='v',
                           marker=dict(color=COLOR[field]))
            graph.append(trace)
        return graph 
开发者ID:architecture-building-systems,项目名称:CityEnergyAnalyst,代码行数:27,代码来源:d_energy_loss_bar.py

示例5: supply_return_ambient_temp_plot

# 需要导入模块: from plotly import offline [as 别名]
# 或者: from plotly.offline import plot [as 别名]
def supply_return_ambient_temp_plot(data_frame, data_frame_2, analysis_fields, title, output_path):
    traces = []
    for field in analysis_fields:
        y = data_frame[field].values
        # sort by ambient temperature, needs some helper variables
        y_old = np.vstack((np.array(data_frame_2.values.T), y))
        y_new = np.vstack((np.array(data_frame_2.values.T), y))
        y_new[0, :] = y_old[0, :][
            y_old[0, :].argsort()]  # y_old[0, :] is the ambient temperature which we are sorting by
        y_new[1, :] = y_old[1, :][y_old[0, :].argsort()]
        trace = go.Scattergl(x=y_new[0], y=y_new[1], name=NAMING[field],
                           marker=dict(color=COLOR[field]),
                           mode='markers')
        traces.append(trace)

    # CREATE FIRST PAGE WITH TIMESERIES
    layout = dict(images=LOGO, title=title, yaxis=dict(title='Temperature [deg C]'),
                  xaxis=dict(title='Ambient Temperature [deg C]'))

    fig = dict(data=traces, layout=layout)
    plot(fig, auto_open=False, filename=output_path)

    return {'data': traces, 'layout': layout} 
开发者ID:architecture-building-systems,项目名称:CityEnergyAnalyst,代码行数:25,代码来源:e_heating_reset_curve.py

示例6: main

# 需要导入模块: from plotly import offline [as 别名]
# 或者: from plotly.offline import plot [as 别名]
def main():
    import cea.config
    import cea.inputlocator
    config = cea.config.Configuration()
    locator = cea.inputlocator.InputLocator(config.scenario)
    # cache = cea.plots.cache.PlotCache(config.project)
    cache = cea.plots.cache.NullPlotCache()
    EnergyDemandDistrictPlot(config.project, {'buildings': None,
                                              'scenario-name': config.scenario_name},
                             cache).plot(auto_open=True)
    EnergyDemandDistrictPlot(config.project, {'buildings': locator.get_zone_building_names()[0:2],
                                              'scenario-name': config.scenario_name},
                             cache).plot(auto_open=True)
    EnergyDemandDistrictPlot(config.project, {'buildings': [locator.get_zone_building_names()[0]],
                                              'scenario-name': config.scenario_name},
                             cache).plot(auto_open=True) 
开发者ID:architecture-building-systems,项目名称:CityEnergyAnalyst,代码行数:18,代码来源:energy_end_use.py

示例7: pvt_district_monthly

# 需要导入模块: from plotly import offline [as 别名]
# 或者: from plotly.offline import plot [as 别名]
def pvt_district_monthly(data_frame, analysis_fields, title, output_path):
    E_analysis_fields_used = data_frame.columns[data_frame.columns.isin(analysis_fields[0:5])].tolist()
    Q_analysis_fields_used = data_frame.columns[data_frame.columns.isin(analysis_fields[5:10])].tolist()

    range = calc_range(data_frame, E_analysis_fields_used, Q_analysis_fields_used)
    # CALCULATE GRAPH
    traces_graphs = calc_graph(E_analysis_fields_used, Q_analysis_fields_used, data_frame)

    # CALCULATE TABLE
    traces_table = calc_table(E_analysis_fields_used, Q_analysis_fields_used, data_frame)

    # PLOT GRAPH
    traces_graphs.append(traces_table)
    layout = go.Layout(images=LOGO, title=title, barmode='stack',
                       yaxis=dict(title='PVT Electricity/Heat production [MWh]', domain=[0.35, 1], rangemode='tozero',
                                  scaleanchor='y2', range=range),
                       yaxis2=dict(overlaying='y', anchor='x', domain=[0.35, 1], range=range))

    fig = go.Figure(data=traces_graphs, layout=layout)
    plot(fig, auto_open=False, filename=output_path)

    return {'data': traces_graphs, 'layout': layout} 
开发者ID:architecture-building-systems,项目名称:CityEnergyAnalyst,代码行数:24,代码来源:b_photovoltaic_thermal_potential.py

示例8: plot_error_curves_pyplot

# 需要导入模块: from plotly import offline [as 别名]
# 或者: from plotly.offline import plot [as 别名]
def plot_error_curves_pyplot(log_files, names, filename=None, metric="top1_err"):
    """Plot error curves using matplotlib.pyplot and save to file."""
    plot_data = prepare_plot_data(log_files, names, metric)
    colors = get_plot_colors(len(names))
    for ind, d in enumerate(plot_data):
        c, lbl = colors[ind], d["test_label"]
        plt.plot(d["x_train"], d["y_train"], "--", c=c, alpha=0.8)
        plt.plot(d["x_test"], d["y_test"], "-", c=c, alpha=0.8, label=lbl)
    plt.title(metric + " vs. epoch\n[dash=train, solid=test]", fontsize=14)
    plt.xlabel("epoch", fontsize=14)
    plt.ylabel(metric, fontsize=14)
    plt.grid(alpha=0.4)
    plt.legend()
    if filename:
        plt.savefig(filename)
        plt.clf()
    else:
        plt.show() 
开发者ID:facebookresearch,项目名称:pycls,代码行数:20,代码来源:plotting.py

示例9: set_plot_format

# 需要导入模块: from plotly import offline [as 别名]
# 或者: from plotly.offline import plot [as 别名]
def set_plot_format(plot_format=None, plot_dpi=None):
    """
    Overwrite the current plot format settings

    :param plot_format: The plot format (e.g. 'png')
    :type  plot_format: str
    :param plot_dpi:    The DPI of the plots
    :type  plot_dpi:    int
    """
    global _PLOT_FORMAT
    global _PLOT_MIME_TYPE
    global _PLOT_DPI
    if plot_format is not None:
        _PLOT_FORMAT = plot_format
        _PLOT_MIME_TYPE = _MIME_TYPES[plot_format]

    if plot_dpi is not None:
        _PLOT_DPI = plot_dpi 
开发者ID:man-group,项目名称:PyBloqs,代码行数:20,代码来源:image.py

示例10: plot_results

# 需要导入模块: from plotly import offline [as 别名]
# 或者: from plotly.offline import plot [as 别名]
def plot_results(results, plot_name='temp-plot.html'):
    '''
        results is a list of dictionaries, each of which defines a trace
         e.g. [{'x': x_data, 'y': y_data, 'name': 'plot_name'}, {...}, {...}]

        Each dictionary's key-value pairs will be passed into go.Scatter
         to generate a trace on the graph

    '''
    traces = []

    for input_args in results:
        traces.append(go.Scatter(**input_args))

    layout = go.Layout(
        title='Trading performance over time',
        yaxis=dict(
            title='Value (USD)'
        ),
    )
    plot(go.Figure(data=traces, layout=layout), filename=plot_name) 
开发者ID:CoinTK,项目名称:CoinTK,代码行数:23,代码来源:backtest.py

示例11: plot2D

# 需要导入模块: from plotly import offline [as 别名]
# 或者: from plotly.offline import plot [as 别名]
def plot2D(data, title=None, viz_type=None, fs=44100, line_names=None):
    """Visualize 2D data using plotly.

    Parameters
    ----------
    data : array_like
        Data to be plotted, separated along the first dimension (rows)
    title : str, optional
        Add title to be displayed on plot
    viz_type : str{None, 'Time', 'ETC', 'LinFFT', 'LogFFT'}, optional
        Type of data to be displayed [Default: None]
    fs : int, optional
        Sampling rate in Hz [Default: 44100]
    line_names : list of str, optional
        Add legend to be displayed on plot, with one entry for each data row [Default: None]
    """
    viz_type = viz_type.strip().upper()  # remove whitespaces and make upper case

    layout = layout_2D(viz_type=viz_type, title=title)
    # noinspection PyTypeChecker
    traces = prepare_2D_traces(data=data, viz_type=viz_type, fs=fs, line_names=line_names)

    showTrace(traces, layout=layout, title=title) 
开发者ID:AppliedAcousticsChalmers,项目名称:sound_field_analysis-py,代码行数:25,代码来源:plot.py

示例12: time_series_memory_per_task_plot

# 需要导入模块: from plotly import offline [as 别名]
# 或者: from plotly.offline import plot [as 别名]
def time_series_memory_per_task_plot(df_resources, resource_type, label):
    if resource_type == "psutil_process_memory_percent":
        yaxis = dict(title="Memory utilization")
        data = [go.Scatter(x=df_resources['timestamp'],
                           y=df_resources[resource_type])]
    else:
        yaxis = dict(title='Memory usage (GB)')
        data = [go.Scatter(x=df_resources['timestamp'],
                           y=[num / 1000000000 for num in df_resources[resource_type].astype(float)])]
    fig = go.Figure(data=data,
                    layout=go.Layout(xaxis=dict(tickformat='%m-%d\n%H:%M:%S',
                                                autorange=True,
                                                title='Time'),
                                     yaxis=yaxis,
                                     title=label))
    return plot(fig, show_link=False, output_type="div", include_plotlyjs=False) 
开发者ID:Parsl,项目名称:parsl,代码行数:18,代码来源:task_plots.py

示例13: save_wordmesh_as_html

# 需要导入模块: from plotly import offline [as 别名]
# 或者: from plotly.offline import plot [as 别名]
def save_wordmesh_as_html(self, coordinates, filename='temp-plot.html', 
                              animate=False, autozoom=True, notebook_mode=False):

        zoom = 1
        labels = ['default label']
        traces = []
        if animate:
            for i in range(coordinates.shape[0]):
                
                traces.append(self._get_trace(coordinates[i]))
                labels = list(map(str,range(coordinates.shape[0])))
                
        else:

            if autozoom:
                zoom = self._get_zoom(coordinates)
            traces = [self._get_trace(coordinates, zoom=zoom)]
            
        layout = self._get_layout(labels, zoom=zoom)
            
        fig = self.generate_figure(traces, labels, layout)
        
        if notebook_mode:
            py.init_notebook_mode(connected=True)
            py.iplot(fig, filename=filename, show_link=False)
        else:
            py.plot(fig, filename=filename, auto_open=False, show_link=False) 
开发者ID:mukund109,项目名称:word-mesh,代码行数:29,代码来源:utils.py

示例14: graph

# 需要导入模块: from plotly import offline [as 别名]
# 或者: from plotly.offline import plot [as 别名]
def graph(self):
        # graph the labels
        trace0 = go.Scatter(y=self.hist, name='Price')
        trace1 = go.Scatter(y=self.savgol, name='Filter')
        trace2 = go.Scatter(y=self.savgol_deriv, name='Derivative', yaxis='y2')
        data = [trace0, trace1, trace2]

        layout = go.Layout(
            title='Labels',
            yaxis=dict(
                title='USDT value'
            ),
            yaxis2=dict(
                title='Derivative of Filter',
                overlaying='y',
                side='right'
            )
        )
        fig = go.Figure(data=data, layout=layout)
        py.plot(fig, filename='../docs/label.html') 
开发者ID:SC4RECOIN,项目名称:LSTM-Crypto-Price-Prediction,代码行数:22,代码来源:generate_labels.py

示例15: test_get_trend_series

# 需要导入模块: from plotly import offline [as 别名]
# 或者: from plotly.offline import plot [as 别名]
def test_get_trend_series(db, client):
    # Create 5 reports each with 1 sample. Each has a single field called 'test_field'
    data_type = factories.SampleDataTypeFactory()
    report = factories.ReportFactory.create_batch(5, samples__data__data_type=data_type)
    db.session.add_all(report)
    db.session.commit()

    # plots = jpi.get('plots/trends/series')
    url = url_for(
        "rest_api.trend_data",
        **{
            "filter": json.dumps([]),
            "fields": json.dumps([data_type.data_key]),
            "control_limits[enabled]": True,
            "control_limits[sigma]": 3,
            "center_line": "mean",
        }
    )
    response = client.get(url, headers={"Content-Type": "application/json"})

    # Check the request was successful
    assert response.status_code == 200, response.json

    # unknown=EXCLUDE ensures we don't keep the ID field when we load at this point
    data = TrendSchema(many=True, unknown=EXCLUDE).load(response.json)

    # Check that there are 4 series (mean, stdev, raw data, outliers)
    assert len(data) == 4

    # Test that this is valid plot data
    plot({"data": data}, validate=True, auto_open=False) 
开发者ID:ewels,项目名称:MegaQC,代码行数:33,代码来源:test_plot.py


注:本文中的plotly.offline.plot方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。