Python plotly.graph_objs 模块,Line() 实例源码

我们从Python开源项目中,提取了以下7个代码示例,用于说明如何使用plotly.graph_objs.Line()

项目:malmo-challenge    作者:Kaixhin    | 项目源码 | 文件源码
def plot_line(xs, ys_population, filename, y_title=''):
  max_colour = 'rgb(0, 132, 180)'
  mean_colour = 'rgb(0, 172, 237)'
  std_colour = 'rgba(29, 202, 255, 0.2)'

  ys = torch.Tensor(ys_population)
  ys_min = ys.min(1)[0].squeeze()
  ys_max = ys.max(1)[0].squeeze()
  ys_mean = ys.mean(1).squeeze()
  ys_std = ys.std(1).squeeze()
  ys_upper, ys_lower = ys_mean + ys_std, ys_mean - ys_std

  trace_max = Scatter(x=xs, y=ys_max.numpy(), line=Line(color=max_colour, dash='dash'), name='Max')
  trace_upper = Scatter(x=xs, y=ys_upper.numpy(), line=Line(color='transparent'), name='+1 Std. Dev.', showlegend=False)
  trace_mean = Scatter(x=xs, y=ys_mean.numpy(), fill='tonexty', fillcolor=std_colour, line=Line(color=mean_colour), name='Mean')
  trace_lower = Scatter(x=xs, y=ys_lower.numpy(), fill='tonexty', fillcolor=std_colour, line=Line(color='transparent'), name='-1 Std. Dev.', showlegend=False)
  trace_min = Scatter(x=xs, y=ys_min.numpy(), line=Line(color=max_colour, dash='dash'), name='Min')

  plotly.offline.plot({
    'data': [trace_upper, trace_mean, trace_lower, trace_min, trace_max],
    'layout': dict(xaxis={'title': 'Step'},
                   yaxis={'title': y_title})
  }, filename=filename, auto_open=False)
项目:lddmm-ot    作者:jeanfeydy    | 项目源码 | 文件源码
def _make_half_violin(x, y, fillcolor='#1f77b4',
                          linecolor='rgb(0, 0, 0)'):
        """
        Produces a sideways probability distribution fig violin plot.
        """
        from plotly.graph_objs import graph_objs

        text = ['(pdf(y), y)=(' + '{:0.2f}'.format(x[i]) +
                ', ' + '{:0.2f}'.format(y[i]) + ')'
                for i in range(len(x))]

        return graph_objs.Scatter(
            x=x,
            y=y,
            mode='lines',
            name='',
            text=text,
            fill='tonextx',
            fillcolor=fillcolor,
            line=graph_objs.Line(width=0.5, color=linecolor, shape='spline'),
            hoverinfo='text',
            opacity=0.5
        )
项目:lddmm-ot    作者:jeanfeydy    | 项目源码 | 文件源码
def _make_quartiles(q1, q3):
        """
        Makes the upper and lower quartiles for a violin plot.
        """
        from plotly.graph_objs import graph_objs

        return graph_objs.Scatter(
            x=[0, 0],
            y=[q1, q3],
            text=['lower-quartile: ' + '{:0.2f}'.format(q1),
                  'upper-quartile: ' + '{:0.2f}'.format(q3)],
            mode='lines',
            line=graph_objs.Line(
                width=4,
                color='rgb(0,0,0)'
            ),
            hoverinfo='text'
        )
项目:ACER    作者:Kaixhin    | 项目源码 | 文件源码
def plot_line(xs, ys_population):
  max_colour = 'rgb(0, 132, 180)'
  mean_colour = 'rgb(0, 172, 237)'
  std_colour = 'rgba(29, 202, 255, 0.2)'

  ys = torch.Tensor(ys_population)
  ys_min = ys.min(1)[0].squeeze()
  ys_max = ys.max(1)[0].squeeze()
  ys_mean = ys.mean(1).squeeze()
  ys_std = ys.std(1).squeeze()
  ys_upper, ys_lower = ys_mean + ys_std, ys_mean - ys_std

  trace_max = Scatter(x=xs, y=ys_max.numpy(), line=Line(color=max_colour, dash='dash'), name='Max')
  trace_upper = Scatter(x=xs, y=ys_upper.numpy(), line=Line(color='transparent'), name='+1 Std. Dev.', showlegend=False)
  trace_mean = Scatter(x=xs, y=ys_mean.numpy(), fill='tonexty', fillcolor=std_colour, line=Line(color=mean_colour), name='Mean')
  trace_lower = Scatter(x=xs, y=ys_lower.numpy(), fill='tonexty', fillcolor=std_colour, line=Line(color='transparent'), name='-1 Std. Dev.', showlegend=False)
  trace_min = Scatter(x=xs, y=ys_min.numpy(), line=Line(color=max_colour, dash='dash'), name='Min')

  plotly.offline.plot({
    'data': [trace_upper, trace_mean, trace_lower, trace_min, trace_max],
    'layout': dict(title='Rewards',
                   xaxis={'title': 'Step'},
                   yaxis={'title': 'Average Reward'})
  }, filename='rewards.html', auto_open=False)
项目:NoisyNet-A3C    作者:Kaixhin    | 项目源码 | 文件源码
def plot_line(xs, ys_population):
  max_colour = 'rgb(0, 132, 180)'
  mean_colour = 'rgb(0, 172, 237)'
  std_colour = 'rgba(29, 202, 255, 0.2)'

  ys = torch.Tensor(ys_population)
  ys_min = ys.min(1)[0].squeeze()
  ys_max = ys.max(1)[0].squeeze()
  ys_mean = ys.mean(1).squeeze()
  ys_std = ys.std(1).squeeze()
  ys_upper, ys_lower = ys_mean + ys_std, ys_mean - ys_std

  trace_max = Scatter(x=xs, y=ys_max.numpy(), line=Line(color=max_colour, dash='dash'), name='Max')
  trace_upper = Scatter(x=xs, y=ys_upper.numpy(), line=Line(color='transparent'), name='+1 Std. Dev.', showlegend=False)
  trace_mean = Scatter(x=xs, y=ys_mean.numpy(), fill='tonexty', fillcolor=std_colour, line=Line(color=mean_colour), name='Mean')
  trace_lower = Scatter(x=xs, y=ys_lower.numpy(), fill='tonexty', fillcolor=std_colour, line=Line(color='transparent'), name='-1 Std. Dev.', showlegend=False)
  trace_min = Scatter(x=xs, y=ys_min.numpy(), line=Line(color=max_colour, dash='dash'), name='Min')

  plotly.offline.plot({
    'data': [trace_upper, trace_mean, trace_lower, trace_min, trace_max],
    'layout': dict(title='Rewards',
                   xaxis={'title': 'Step'},
                   yaxis={'title': 'Average Reward'})
  }, filename='rewards.html', auto_open=False)
项目:lddmm-ot    作者:jeanfeydy    | 项目源码 | 文件源码
def _make_non_outlier_interval(d1, d2):
        """
        Returns the scatterplot fig of most of a violin plot.
        """
        from plotly.graph_objs import graph_objs

        return graph_objs.Scatter(
            x=[0, 0],
            y=[d1, d2],
            name='',
            mode='lines',
            line=graph_objs.Line(width=1.5,
                                 color='rgb(0,0,0)')
        )
项目:a3c-mujoco    作者:Feryal    | 项目源码 | 文件源码
def plot_line(xs, ys_population):
    max_colour = 'rgb(0, 132, 180)'
    mean_colour = 'rgb(0, 172, 237)'
    std_colour = 'rgba(29, 202, 255, 0.2)'

    ys = torch.Tensor(ys_population)
    ys_min = ys.min(1)[0].squeeze()
    ys_max = ys.max(1)[0].squeeze()
    ys_mean = ys.mean(1).squeeze()
    ys_std = ys.std(1).squeeze()
    ys_upper, ys_lower = ys_mean + ys_std, ys_mean - ys_std

    trace_max = Scatter(
        x=xs,
        y=ys_max.numpy(),
        line=Line(
            color=max_colour, dash='dash'),
        name='Max')
    trace_upper = Scatter(
        x=xs,
        y=ys_upper.numpy(),
        line=Line(color='transparent'),
        name='+1 Std. Dev.',
        showlegend=False)
    trace_mean = Scatter(
        x=xs,
        y=ys_mean.numpy(),
        fill='tonexty',
        fillcolor=std_colour,
        line=Line(color=mean_colour),
        name='Mean')
    trace_lower = Scatter(
        x=xs,
        y=ys_lower.numpy(),
        fill='tonexty',
        fillcolor=std_colour,
        line=Line(color='transparent'),
        name='-1 Std. Dev.',
        showlegend=False)
    trace_min = Scatter(
        x=xs,
        y=ys_min.numpy(),
        line=Line(
            color=max_colour, dash='dash'),
        name='Min')

    plotly.offline.plot(
        {
            'data':
            [trace_upper, trace_mean, trace_lower, trace_min, trace_max],
            'layout': dict(
                title='Rewards',
                xaxis={'title': 'Step'},
                yaxis={'title': 'Average Reward'})
        },
        filename=os.path.join('results', 'rewards.html'),
        auto_open=False)