當前位置: 首頁>>代碼示例>>Python>>正文


Python graph_objects.Figure方法代碼示例

本文整理匯總了Python中plotly.graph_objects.Figure方法的典型用法代碼示例。如果您正苦於以下問題:Python graph_objects.Figure方法的具體用法?Python graph_objects.Figure怎麽用?Python graph_objects.Figure使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在plotly.graph_objects的用法示例。


在下文中一共展示了graph_objects.Figure方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: __init__

# 需要導入模塊: from plotly import graph_objects [as 別名]
# 或者: from plotly.graph_objects import Figure [as 別名]
def __init__(self):
        self.fig = go.Figure()

        # Vertices of the faces
        self.x_face = []
        self.y_face = []
        self.z_face = []

        # Connectivity and color of the faces
        self.i_face = []
        self.j_face = []
        self.k_face = []
        self.intensity_face = []

        # Vertices of the lines
        self.x_line = []
        self.y_line = []
        self.z_line = []

        # Vertices of the streamlines
        self.x_streamline = []
        self.y_streamline = []
        self.z_streamline = [] 
開發者ID:peterdsharpe,項目名稱:AeroSandbox,代碼行數:25,代碼來源:visualization.py

示例2: plot

# 需要導入模塊: from plotly import graph_objects [as 別名]
# 或者: from plotly.graph_objects import Figure [as 別名]
def plot(self, **kwargs):
        """Plot stiffness coefficient vs frequency.

        Parameters
        ----------
        **kwargs : optional
            Additional key word arguments can be passed to change the plot layout only
            (e.g. width=1000, height=800, ...).
            *See Plotly Python Figure Reference for more information.

        Returns
        -------
        fig : Plotly graph_objects.Figure()
            The figure object with the plot.

        Example
        -------
        >>> bearing = bearing_example()
        >>> fig = bearing.kxx.plot()
        >>> # fig.show()
        """
        fig = super().plot(**kwargs)
        fig.update_yaxes(title_text="<b>Stiffness (N/m)</b>")

        return fig 
開發者ID:ross-rotordynamics,項目名稱:ross,代碼行數:27,代碼來源:bearing_seal_element.py

示例3: savefig

# 需要導入模塊: from plotly import graph_objects [as 別名]
# 或者: from plotly.graph_objects import Figure [as 別名]
def savefig(
            self,
            filename: str,
            figsize: Tuple[Optional[int]] = (None, None),
            scale: float = 1,
            transparent: bool = False
    ) -> None:
        """Save the figure.

        Args:
            filename: Filename to save to.
            figsize: Figure size (W x H) in pixels.
            scale: Scale of the output figure.
            transparent: Whether to use transparent background.
        """
        if transparent:
            plot_color = self._fig.layout['plot_bgcolor']
            paper_color = self._fig.layout['paper_bgcolor']
            self._fig.update_layout(paper_bgcolor='rgba(0,0,0,0)',
                                    plot_bgcolor='rgba(0,0,0,0)')
        self._fig.write_image(filename, width=figsize[0], height=figsize[1], scale=scale)
        if transparent:
            self._fig.update_layout(plot_bgcolor=plot_color,
                                    paper_bgcolor=paper_color) 
開發者ID:Qiskit,項目名稱:qiskit-ibmq-provider,代碼行數:26,代碼來源:plotly_wrapper.py

示例4: make_chart

# 需要導入模塊: from plotly import graph_objects [as 別名]
# 或者: from plotly.graph_objects import Figure [as 別名]
def make_chart(title):
    import json

    import plotly.graph_objects as go
    import plotly

    layout = go.Layout(title=title)

    data = go.Scatter(
        x=[1, 2, 3, 4],
        y=[10, 11, 12, 13],
        mode="markers",
        marker=dict(size=[40, 60, 80, 100], color=[0, 1, 2, 3]),
    )

    fig = go.Figure(data=data)
    fig = json.dumps(fig, cls=plotly.utils.PlotlyJSONEncoder)
    layout = json.dumps(layout, cls=plotly.utils.PlotlyJSONEncoder)
    return fig, layout 
開發者ID:apryor6,項目名稱:flaskerize,代碼行數:21,代碼來源:view.py

示例5: performance_plot

# 需要導入模塊: from plotly import graph_objects [as 別名]
# 或者: from plotly.graph_objects import Figure [as 別名]
def performance_plot(perf, title):
    formats = ['nbformat'] + JUPYTEXT_FORMATS
    mean = perf.groupby('implementation').mean().loc[formats]
    std = perf.groupby('implementation').std().loc[formats]
    data = [go.Bar(x=mean.index,
                   y=mean[col],
                   error_y=dict(
                       type='data',
                       array=std[col],
                       color=color,
                       thickness=0.5
                   ) if col != 'size' else dict(),
                   name=col,
                   yaxis={'read': 'y1', 'write': 'y2', 'size': 'y3'}[col])
            for col, color in zip(mean.columns, DEFAULT_PLOTLY_COLORS)]
    layout = go.Layout(title=title,
                       xaxis=dict(title='Implementation', anchor='y3'),
                       yaxis=dict(domain=[0.7, 1], title='Read (secs)'),
                       yaxis2=dict(domain=[0.35, .65], title='Write (secs)'),
                       yaxis3=dict(domain=[0, .3], title='Size')
                       )
    return go.Figure(data=data, layout=layout) 
開發者ID:mwouts,項目名稱:jupytext,代碼行數:24,代碼來源:Benchmarking Jupytext.py

示例6: create_figure

# 需要導入模塊: from plotly import graph_objects [as 別名]
# 或者: from plotly.graph_objects import Figure [as 別名]
def create_figure(self):
        f = go.Figure()
        self._set_layout(f)
        return f 
開發者ID:rte-france,項目名稱:Grid2Op,代碼行數:6,代碼來源:PlotPlotly.py

示例7: init_fig

# 需要導入模塊: from plotly import graph_objects [as 別名]
# 或者: from plotly.graph_objects import Figure [as 別名]
def init_fig(self, fig, reward, done, timestamp):
        if fig is None:
            fig = go.Figure()
        elif not isinstance(fig, self.type_fig_allowed):
            raise PlotError("PlotPlotly cannot plot on figure of type {}. The accepted type is {}. You provided an "
                            "invalid argument for \"fig\"".format(type(fig), self.type_fig_allowed))
        return fig 
開發者ID:rte-france,項目名稱:Grid2Op,代碼行數:9,代碼來源:PlotPlotly.py

示例8: write_worker_log

# 需要導入模塊: from plotly import graph_objects [as 別名]
# 或者: from plotly.graph_objects import Figure [as 別名]
def write_worker_log(self, worker_logs: List[dict]):
        """Log the mean scores of each episode per update step to wandb."""
        # NOTE: Worker plots are passed onto wandb.log as matplotlib.pyplot
        #       since wandb doesn't support logging multiple lines to single plot
        if self.args.log:
            self.set_wandb()
            # Plot individual workers
            fig = go.Figure()
            worker_id = 0
            for worker_log in worker_logs:
                fig.add_trace(
                    go.Scatter(
                        x=list(worker_log.keys()),
                        y=smoothen_graph(list(worker_log.values())),
                        mode="lines",
                        name=f"Worker {worker_id}",
                        line=dict(width=2),
                    )
                )
                worker_id = worker_id + 1

            # Plot mean scores
            steps = worker_logs[0].keys()
            mean_scores = []
            for step in steps:
                each_scores = [worker_log[step] for worker_log in worker_logs]
                mean_scores.append(np.mean(each_scores))

            fig.add_trace(
                go.Scatter(
                    x=list(worker_logs[0].keys()),
                    y=mean_scores,
                    mode="lines+markers",
                    name="Mean scores",
                    line=dict(width=5),
                )
            )

            # Write to wandb
            wandb.log({"Worker scores": fig}) 
開發者ID:medipixel,項目名稱:rl_algorithms,代碼行數:42,代碼來源:distributed_logger.py

示例9: plot_score

# 需要導入模塊: from plotly import graph_objects [as 別名]
# 或者: from plotly.graph_objects import Figure [as 別名]
def plot_score(all_scores):
    fig = go.Figure(data=go.Bar(y=all_scores))
    fig.write_html('DQN_CNN_Trend_figure.html') 
開發者ID:FitMachineLearning,項目名稱:FitML,代碼行數:5,代碼來源:ATARI_DQN_CNN.py

示例10: plot_score

# 需要導入模塊: from plotly import graph_objects [as 別名]
# 或者: from plotly.graph_objects import Figure [as 別名]
def plot_score(all_scores):
    fig = go.Figure(data=go.Bar(y=all_scores))
    fig.write_html('Trend_figure.html') 
開發者ID:FitMachineLearning,項目名稱:FitML,代碼行數:5,代碼來源:Advantage_Actor_Critic.py

示例11: plot_rewards_over_trials

# 需要導入模塊: from plotly import graph_objects [as 別名]
# 或者: from plotly.graph_objects import Figure [as 別名]
def plot_rewards_over_trials(rewards, env_name, save=False):
    import plotly.graph_objects as go
    data = []
    traces = []
    colors = plt.get_cmap('tab10').colors

    i = 0
    cs_str = 'rgb' + str(colors[i])
    ys = np.stack(rewards)
    data.append(ys)
    err_traces, xs, ys = generate_errorbar_traces(np.asarray(data[i]), color=cs_str, name=f"simulation")
    for t in err_traces:
        traces.append(t)

    layout = dict(title=f"Learning Curve Reward vs Number of Trials (Env: {env_name})",
                  xaxis={'title': 'Trial Num'},
                  yaxis={'title': 'Cum. Reward'},
                  plot_bgcolor='white',
                  showlegend=False,
                  font=dict(family='Times New Roman', size=30, color='#7f7f7f'),
                  height=1000,
                  width=1500,
                  legend={'x': .83, 'y': .05, 'bgcolor': 'rgba(50, 50, 50, .03)'})

    fig = {
        'data': traces,
        'layout': layout
    }

    fig = go.Figure(fig)

    if save:
        fig.write_image(os.getcwd() + "/learning.png")
    else:
        fig.show()

    return fig 
開發者ID:natolambert,項目名稱:dynamicslearn,代碼行數:39,代碼來源:plotly.py

示例12: plot_learning

# 需要導入模塊: from plotly import graph_objects [as 別名]
# 或者: from plotly.graph_objects import Figure [as 別名]
def plot_learning(exp, cfg):
    objective_means = np.array([[exp.trials[trial].objective_mean] for trial in exp.trials])
    cumulative = optimization_trace_single_method(
        y=np.maximum.accumulate(objective_means.T, axis=1), ylabel=cfg.metric.name,
        trace_color=(83, 78, 194),
        # optimum=-3.32237,  # Known minimum objective for Hartmann6 function.
    )
    all = optimization_trace_single_method(
        y=objective_means.T, ylabel=cfg.metric.name,
        model_transitions=[cfg.bo.random], trace_color=(114, 110, 180),
        # optimum=-3.32237,  # Known minimum objective for Hartmann6 function.
    )
    layout_learn = cumulative[0]['layout']
    layout_learn['paper_bgcolor'] = 'rgba(0,0,0,0)'
    layout_learn['plot_bgcolor'] = 'rgba(0,0,0,0)'

    d1 = cumulative[0]['data']
    d2 = all[0]['data']

    for t in d1:
        t['legendgroup'] = cfg.metric.name + ", cum. max"
        if 'name' in t and t['name'] == 'Generator change':
            t['name'] = 'End Random Iterations'
        else:
            t['name'] = cfg.metric.name + ", cum. max"

    for t in d2:
        t['legendgroup'] = cfg.metric.name
        if 'name' in t and t['name'] == 'Generator change':
            t['name'] = 'End Random Iterations'
        else:
            t['name'] = cfg.metric.name

    fig = {
        "data": d1 + d2,  # data,
        "layout": layout_learn,
    }
    import plotly.graph_objects as go
    return go.Figure(fig) 
開發者ID:natolambert,項目名稱:dynamicslearn,代碼行數:41,代碼來源:simulate_bopid.py

示例13: test_plots

# 需要導入模塊: from plotly import graph_objects [as 別名]
# 或者: from plotly.graph_objects import Figure [as 別名]
def test_plots():
    bearing = fluid_flow_short_numerical()
    bearing.calculate_pressure_matrix_numerical()
    figure_type = type(go.Figure())
    assert isinstance(plot_shape(bearing), figure_type)
    assert isinstance(plot_eccentricity(bearing), figure_type)
    assert isinstance(plot_pressure_theta(bearing), figure_type)
    assert isinstance(plot_pressure_z(bearing), figure_type)
    assert isinstance(plot_pressure_theta_cylindrical(bearing), figure_type)
    assert isinstance(plot_pressure_surface(bearing), figure_type) 
開發者ID:ross-rotordynamics,項目名稱:ross,代碼行數:12,代碼來源:test_fluid_flow.py

示例14: __init__

# 需要導入模塊: from plotly import graph_objects [as 別名]
# 或者: from plotly.graph_objects import Figure [as 別名]
def __init__(self, fig: go.Figure):
        """PlotlyFigure class.

        Args:
            fig: Figure to use.
        """
        self._fig = fig 
開發者ID:Qiskit,項目名稱:qiskit-ibmq-provider,代碼行數:9,代碼來源:plotly_wrapper.py

示例15: build_box_subplots

# 需要導入模塊: from plotly import graph_objects [as 別名]
# 或者: from plotly.graph_objects import Figure [as 別名]
def build_box_subplots(stat: pd.DataFrame) -> go.Figure:
        """Create a figure with box subplots showing fields coverages for jobs.

        Args:
            stat: a dataframe with field coverages

        Returns:
            A figure with box subplots
        """
        stat = stat.drop(columns=["std", "mean", "target deviation"])
        traces = [
            go.Box(
                y=row[1],
                name=row[0],
                boxpoints="all",
                jitter=0.3,
                boxmean="sd",
                hoverinfo="y",
            )
            for row in stat.iterrows()
        ]
        cols = 4
        rows = math.ceil(len(stat) / cols)
        fig = make_subplots(rows=rows, cols=cols)
        x = 0
        for i, j in itertools.product(range(1, rows + 1), range(1, cols + 1)):
            if x == len(traces):
                break
            fig.append_trace(traces[x], i, j)
            x += 1

        fig.update_layout(height=rows * 300 + 200, width=cols * 300, showlegend=False)
        fig.update_yaxes(tickformat=".4p")
        return fig 
開發者ID:scrapinghub,項目名稱:arche,代碼行數:36,代碼來源:result.py


注:本文中的plotly.graph_objects.Figure方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。