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


Python plotly.plot方法代码示例

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


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

示例1: running_times

# 需要导入模块: from plotly import plotly [as 别名]
# 或者: from plotly.plotly import plot [as 别名]
def running_times():
    rospack = rospkg.RosPack()
    data_path = os.path.join(rospack.get_path('vslam_evaluation'), 'out')
    df = pd.read_csv(os.path.join(data_path, 'runtimes.txt'),
        header=None,
        index_col=0)

    bars = []

    for col_idx in df:
        this_stack = df[col_idx].dropna()
        bars.append(
            go.Bar(
                x=this_stack.index,
                y=this_stack.values,
                name='Thread {}'.format(col_idx)))

    layout = go.Layout(
        barmode='stack',
        yaxis={'title': 'Running time [s]'})

    fig = go.Figure(data=bars, layout=layout)

    url = py.plot(fig, filename='vslam_eval_run_times') 
开发者ID:nicolov,项目名称:vslam_evaluation,代码行数:26,代码来源:plot_plotly.py

示例2: run_query

# 需要导入模块: from plotly import plotly [as 别名]
# 或者: from plotly.plotly import plot [as 别名]
def run_query(ont, aset, args):
    """
    Basic querying by positive/negative class lists
    """
    subjects = aset.query(args.query, args.negative)
    for s in subjects:
        print("{} {}".format(s, str(aset.label(s))))

    if args.plot:
        import plotly.plotly as py
        import plotly.graph_objs as go
        tups = aset.query_associations(subjects=subjects)
        z, xaxis, yaxis = tuple_to_matrix(tups)
        spacechar = " "
        xaxis = mk_axis(xaxis, aset, args, spacechar=" ")
        yaxis = mk_axis(yaxis, aset, args, spacechar=" ")
        logging.info("PLOTTING: {} x {} = {}".format(xaxis, yaxis, z))
        trace = go.Heatmap(z=z,
                           x=xaxis,
                           y=yaxis)
        data=[trace]
        py.plot(data, filename='labelled-heatmap') 
开发者ID:biolink,项目名称:ontobio,代码行数:24,代码来源:ontobio-assoc.py

示例3: run_query_associations

# 需要导入模块: from plotly import plotly [as 别名]
# 或者: from plotly.plotly import plot [as 别名]
def run_query_associations(ont, aset, args):
    if args.dendrogram:
        plot_subject_term_matrix(ont, aset, args)
        return
    import plotly.plotly as py
    import plotly.graph_objs as go
    tups = aset.query_associations(subjects=args.subjects)
    for (s,c) in tups:
        print("{} {}".format(s, c))
    z, xaxis, yaxis = tuple_to_matrix(tups)
    xaxis = mk_axis(xaxis, aset, args)
    yaxis = mk_axis(yaxis, aset, args)
    logging.info("PLOTTING: {} x {} = {}".format(xaxis, yaxis, z))
    trace = go.Heatmap(z=z,
                       x=xaxis,
                       y=yaxis)
    data=[trace]
    py.plot(data, filename='labelled-heatmap')
    #plot_dendrogram(z, xaxis, yaxis)
    
# TODO: fix this really dumb implementation 
开发者ID:biolink,项目名称:ontobio,代码行数:23,代码来源:ontobio-assoc.py

示例4: __init__

# 需要导入模块: from plotly import plotly [as 别名]
# 或者: from plotly.plotly import plot [as 别名]
def __init__(self,
               apiKey=None,
               username=None,
               experimentName="experiment"):
    # Instantiate API credentials.
    try:
      self.apiKey = apiKey if apiKey else os.environ["PLOTLY_API_KEY"]
    except:
      print ("Missing PLOTLY_API_KEY environment variable. If you have a "
        "key, set it with $ export PLOTLY_API_KEY=api_key\n"
        "You can retrieve a key by registering for the Plotly API at "
        "http://www.plot.ly")
      raise OSError("Missing API key.")
    try:
      self.username = username if username else os.environ["PLOTLY_USERNAME"]
    except:
      print ("Missing PLOTLY_USERNAME environment variable. If you have a "
        "username, set it with $ export PLOTLY_USERNAME=username\n"
        "You can sign up for the Plotly API at http://www.plot.ly")
      raise OSError("Missing username.")

    py.sign_in(self.username, self.apiKey)

    self.experimentName = experimentName 
开发者ID:numenta,项目名称:nupic.fluent,代码行数:26,代码来源:plotting.py

示例5: graph_OHLC

# 需要导入模块: from plotly import plotly [as 别名]
# 或者: from plotly.plotly import plot [as 别名]
def graph_OHLC(self):
        #not quite there, but the other one works, which is what i really care about
        OHLC_trace = go.Ohlc(x=self.OHLC_data.Date_Time,
                open=self.OHLC_data.Open,
                high=self.OHLC_data.High,
                low=self.OHLC_data.Low,
                close=self.OHLC_data.Close,
                name="OHLC Data",
                increasing=dict(line=dict(color= '#408e4a')),
                decreasing=dict(line=dict(color= '#cc2718')))

        swing_data = pd.read_csv(self.swing_file, names=['Date_Time', 'Price', 'Direction', 'Row'], parse_dates=True)
        swing_trace = go.Scatter(
            x = swing_data.Date_Time,
            y = swing_data.Price,
            mode = 'lines+markers',
            name = 'Swings',
            line = dict(
                color = ('rgb(111, 126, 130)'),
                width = 3)
        )

        data = [OHLC_trace, swing_trace]
        layout = go.Layout(xaxis = dict(rangeslider = dict(visible = False)), title= self.data_file[:-4])

        fig = go.Figure(data=data, layout=layout)
        py.plot(fig, filename=self.data_file + ".html", output_type='file') 
开发者ID:Wkemery,项目名称:ElliotWaveAnalysis,代码行数:29,代码来源:Swings.py

示例6: export_OHLC_graph

# 需要导入模块: from plotly import plotly [as 别名]
# 或者: from plotly.plotly import plot [as 别名]
def export_OHLC_graph(self):

        if self.update:
            print("Did update, graph is screwy")
        OHLC_trace = go.Ohlc(x=self.OHLC_data.Date_Time,
                open=self.OHLC_data.Open,
                high=self.OHLC_data.High,
                low=self.OHLC_data.Low,
                close=self.OHLC_data.Close,
                name="OHLC Data",
                increasing=dict(line=dict(color= '#408e4a')),
                decreasing=dict(line=dict(color= '#cc2718')))

        swing_data = pd.read_csv(self.swing_file, names=['Date_Time', 'Price', 'Direction', 'Row'], parse_dates=True)
        swing_trace = go.Scatter(
            x = swing_data.Date_Time,
            y = swing_data.Price,
            mode = 'lines+markers',
            name = 'Swings',
            line = dict(
                color = ('rgb(111, 126, 130)'),
                width = 3)
        )

        data = [OHLC_trace, swing_trace]

        layout = {
            'title': self.data_file[:-4],
            'yaxis': {'title': 'Price'},
        }
        fig = go.Figure(data=data, layout=layout)
        offline.plot(fig, output_type='file',filename=self.data_file + ".html", image='png', image_filename=self.data_file) 
开发者ID:Wkemery,项目名称:ElliotWaveAnalysis,代码行数:34,代码来源:Swings.py

示例7: position_comparison

# 需要导入模块: from plotly import plotly [as 别名]
# 或者: from plotly.plotly import plot [as 别名]
def position_comparison():
    plot_layout = go.Layout(
        title='X position comparison',
        xaxis={'title': 'Time [s]'},
        yaxis={'title': 'X position [m]'}
    )

    plot_data = []

    for i, (label, bag_file_name, odometry_topic_name) in enumerate(comparisons):
        td_visual, td_vicon = load_one_comparison(bag_file_name, odometry_topic_name)

        plot_data.append(
            go.Scatter(x=td_visual.col(0)[::4],
                y=td_visual.col(1)[::4],
                mode='lines+markers',
                name=label,
                marker={'maxdisplayed': 150}))

        if i == 0:
            # Only plot ground truth once
            plot_data.append(
                go.Scatter(x=td_vicon.col(0)[::20],
                    y=td_vicon.col(1)[::20],
                    mode='lines+markers',
                    name='Truth',
                    marker={'maxdisplayed': 150}))

    fig = go.Figure(data=plot_data, layout=plot_layout)
    url = py.plot(fig, filename='vslam_eval_x_pos') 
开发者ID:nicolov,项目名称:vslam_evaluation,代码行数:32,代码来源:plot_plotly.py

示例8: plot_intersections

# 需要导入模块: from plotly import plotly [as 别名]
# 或者: from plotly.plotly import plot [as 别名]
def plot_intersections(ont, aset, args):
    import plotly.plotly as py
    import plotly.graph_objs as go
    (z, xaxis, yaxis) = create_intersection_matrix(ont, aset, args)
    trace = go.Heatmap(z=z,
                       x=xaxis,
                       y=yaxis)
    data=[trace]
    py.plot(data, filename='labelled-heatmap') 
开发者ID:biolink,项目名称:ontobio,代码行数:11,代码来源:ontobio-assoc.py

示例9: _plot_option_logic

# 需要导入模块: from plotly import plotly [as 别名]
# 或者: from plotly.plotly import plot [as 别名]
def _plot_option_logic(plot_options_from_call_signature):
    """
    Given some plot_options as part of a plot call, decide on final options.
    Precedence:
        1 - Start with DEFAULT_PLOT_OPTIONS
        2 - Update each key with ~/.plotly/.config options (tls.get_config)
        3 - Update each key with session plot options (set by py.sign_in)
        4 - Update each key with plot, iplot call signature options

    """
    default_plot_options = copy.deepcopy(DEFAULT_PLOT_OPTIONS)
    file_options = tools.get_config_file()
    session_options = get_session_plot_options()
    plot_options_from_call_signature = copy.deepcopy(plot_options_from_call_signature)

    # Validate options and fill in defaults w world_readable and sharing
    for option_set in [plot_options_from_call_signature,
                       session_options, file_options]:
        utils.validate_world_readable_and_sharing_settings(option_set)
        utils.set_sharing_and_world_readable(option_set)

        # dynamic defaults
        if ('filename' in option_set and
                'fileopt' not in option_set):
            option_set['fileopt'] = 'overwrite'

    user_plot_options = {}
    user_plot_options.update(default_plot_options)
    user_plot_options.update(file_options)
    user_plot_options.update(session_options)
    user_plot_options.update(plot_options_from_call_signature)
    user_plot_options = {k: v for k, v in user_plot_options.items()
                         if k in default_plot_options}

    return user_plot_options 
开发者ID:jeanfeydy,项目名称:lddmm-ot,代码行数:37,代码来源:plotly.py

示例10: plot_mpl

# 需要导入模块: from plotly import plotly [as 别名]
# 或者: from plotly.plotly import plot [as 别名]
def plot_mpl(fig, resize=True, strip_style=False, update=None, **plot_options):
    """Replot a matplotlib figure with plotly.

    This function:
    1. converts the mpl figure into JSON (run help(plolty.tools.mpl_to_plotly))
    2. makes a request to Plotly to save this figure in your account
    3. opens your figure in a browser tab OR returns the unique figure url

    Positional agruments:
    fig -- a figure object from matplotlib

    Keyword arguments:
    resize (default=True) -- allow plotly to choose the figure size
    strip_style (default=False) -- allow plotly to choose style options
    update (default=None) -- update the resulting figure with an 'update'
        dictionary-like object resembling a plotly 'Figure' object

    Additional keyword arguments:
    plot_options -- run help(plotly.plotly.plot)

    """
    fig = tools.mpl_to_plotly(fig, resize=resize, strip_style=strip_style)
    if update and isinstance(update, dict):
        fig.update(update)
        fig.validate()
    elif update is not None:
        raise exceptions.PlotlyGraphObjectError(
            "'update' must be dictionary-like and a valid plotly Figure "
            "object. Run 'help(plotly.graph_objs.Figure)' for more info."
        )
    return plot(fig, **plot_options) 
开发者ID:jeanfeydy,项目名称:lddmm-ot,代码行数:33,代码来源:plotly.py

示例11: __init__

# 需要导入模块: from plotly import plotly [as 别名]
# 或者: from plotly.plotly import plot [as 别名]
def __init__(self, stream_id):
        """
        Initialize a Stream object with your unique stream_id.
        Find your stream_id at {plotly_domain}/settings.

        For more help, see: `help(plotly.plotly.Stream)`
        or see examples and tutorials here:
        https://plot.ly/python/streaming/

        """
        self.stream_id = stream_id
        self.connected = False
        self._stream = None 
开发者ID:jeanfeydy,项目名称:lddmm-ot,代码行数:15,代码来源:plotly.py

示例12: open

# 需要导入模块: from plotly import plotly [as 别名]
# 或者: from plotly.plotly import plot [as 别名]
def open(self):
        """
        Open streaming connection to plotly.

        For more help, see: `help(plotly.plotly.Stream)`
        or see examples and tutorials here:
        https://plot.ly/python/streaming/

        """
        streaming_specs = self.get_streaming_specs()
        self._stream = chunked_requests.Stream(**streaming_specs) 
开发者ID:jeanfeydy,项目名称:lddmm-ot,代码行数:13,代码来源:plotly.py

示例13: ishow

# 需要导入模块: from plotly import plotly [as 别名]
# 或者: from plotly.plotly import plot [as 别名]
def ishow(cls, figure_or_data, format='png', width=None, height=None,
              scale=None):
        """Display a static image of the plot described by `figure_or_data`
        in an IPython Notebook.

        positional arguments:
        - figure_or_data: The figure dict-like or data list-like object that
                          describes a plotly figure.
                          Same argument used in `py.plot`, `py.iplot`,
                          see https://plot.ly/python for examples
        - format: 'png', 'svg', 'jpeg', 'pdf'
        - width: output width
        - height: output height
        - scale: Increase the resolution of the image by `scale` amount
               Only valid for PNG and JPEG images.

        example:
        ```
        import plotly.plotly as py
        fig = {'data': [{'x': [1, 2, 3], 'y': [3, 1, 5], 'type': 'bar'}]}
        py.image.ishow(fig, 'png', scale=3)
        """
        if format == 'pdf':
            raise exceptions.PlotlyError(
                "Aw, snap! "
                "It's not currently possible to embed a pdf into "
                "an IPython notebook. You can save the pdf "
                "with the `image.save_as` or you can "
                "embed an png, jpeg, or svg.")
        img = cls.get(figure_or_data, format, width, height, scale)
        from IPython.display import display, Image, SVG
        if format == 'svg':
            display(SVG(img))
        else:
            display(Image(img)) 
开发者ID:jeanfeydy,项目名称:lddmm-ot,代码行数:37,代码来源:plotly.py

示例14: delete

# 需要导入模块: from plotly import plotly [as 别名]
# 或者: from plotly.plotly import plot [as 别名]
def delete(cls, grid=None, grid_url=None):
        """
        Delete a grid from your Plotly account.

        Only one of `grid` or `grid_url` needs to be specified.

        `grid` is a plotly.grid_objs.Grid object that has already
               been uploaded to Plotly.

        `grid_url` is the URL of the Plotly grid to delete

        Usage example 1: Upload a grid to plotly, then delete it
        ```
        from plotly.grid_objs import Grid, Column
        import plotly.plotly as py
        column_1 = Column([1, 2, 3], 'time')
        column_2 = Column([4, 2, 5], 'voltage')
        grid = Grid([column_1, column_2])
        py.grid_ops.upload(grid, 'time vs voltage')

        # now delete it, and free up that filename
        py.grid_ops.delete(grid)
        ```

        Usage example 2: Delete a plotly grid by url
        ```
        import plotly.plotly as py

        grid_url = 'https://plot.ly/~chris/3'
        py.grid_ops.delete(grid_url=grid_url)
        ```

        """
        grid_id = _api_v2.parse_grid_id_args(grid, grid_url)
        api_url = _api_v2.api_url('grids') + '/' + grid_id
        res = requests.delete(api_url, headers=_api_v2.headers(),
                              verify=get_config()['plotly_ssl_verification'])
        _api_v2.response_handler(res) 
开发者ID:jeanfeydy,项目名称:lddmm-ot,代码行数:40,代码来源:plotly.py

示例15: parse_grid_id_args

# 需要导入模块: from plotly import plotly [as 别名]
# 或者: from plotly.plotly import plot [as 别名]
def parse_grid_id_args(cls, grid, grid_url):
        """
        Return the grid_id from the non-None input argument.

        Raise an error if more than one argument was supplied.

        """
        if grid is not None:
            id_from_grid = grid.id
        else:
            id_from_grid = None
        args = [id_from_grid, grid_url]
        arg_names = ('grid', 'grid_url')

        supplied_arg_names = [arg_name for arg_name, arg
                              in zip(arg_names, args) if arg is not None]

        if not supplied_arg_names:
            raise exceptions.InputError(
                "One of the two keyword arguments is required:\n"
                "    `grid` or `grid_url`\n\n"
                "grid: a plotly.graph_objs.Grid object that has already\n"
                "    been uploaded to Plotly.\n\n"
                "grid_url: the url where the grid can be accessed on\n"
                "    Plotly, e.g. 'https://plot.ly/~chris/3043'\n\n"
            )
        elif len(supplied_arg_names) > 1:
            raise exceptions.InputError(
                "Only one of `grid` or `grid_url` is required. \n"
                "You supplied both. \n"
            )
        else:
            supplied_arg_name = supplied_arg_names.pop()
            if supplied_arg_name == 'grid_url':
                path = six.moves.urllib.parse.urlparse(grid_url).path
                file_owner, file_id = path.replace("/~", "").split('/')[0:2]
                return '{0}:{1}'.format(file_owner, file_id)
            else:
                return grid.id 
开发者ID:jeanfeydy,项目名称:lddmm-ot,代码行数:41,代码来源:plotly.py


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