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


Python plotly.offline方法代碼示例

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


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

示例1: go_offline

# 需要導入模塊: import plotly [as 別名]
# 或者: from plotly import offline [as 別名]
def go_offline(connected=False):
    """Take plotting offline.

    __PLOTLY_OFFLINE_INITIALIZED is a secret variable
    in plotly/offline/offline.py.

    Parameters
    ---------
        connected : bool
            Determines if init_notebook_mode should be set to 'connected'.
            99% of time will not need to touch this.

    """
    try:
        pyo.init_notebook_mode(connected)
    except TypeError:
        pyo.init_notebook_mode()

    pyo.__PLOTLY_OFFLINE_INITIALIZED = True 
開發者ID:plotly,項目名稱:dash-technical-charting,代碼行數:21,代碼來源:tools.py

示例2: check_url

# 需要導入模塊: import plotly [as 別名]
# 或者: from plotly import offline [as 別名]
def check_url(url=None):
    """Check URL integrity.

    Parameters
    ----------
        url : string
            URL to be checked.

    """
    if url is None:
        if 'http' not in get_config_file()['offline_url']:
            raise Exception("No default offline URL set. "
                            "Please run "
                            "quantmod.set_config_file(offline_url=YOUR_URL) "
                            "to set the default offline URL.")
        else:
            url = get_config_file()['offline_url']

    if url is not None:
        if not isinstance(url, six.string_types):
            raise TypeError("Invalid url '{0}'. "
                            "It should be string."
                            .format(url))

    pyo.download_plotlyjs(url) 
開發者ID:plotly,項目名稱:dash-technical-charting,代碼行數:27,代碼來源:tools.py

示例3: ensure_plotly

# 需要導入模塊: import plotly [as 別名]
# 或者: from plotly import offline [as 別名]
def ensure_plotly():
    global _plotly_enabled
    try:
        import plotly

        if not _plotly_enabled:
            import plotly.graph_objs
            import plotly.figure_factory
            import plotly.offline

            # This injects javascript and should happen only once
            plotly.offline.init_notebook_mode()
            _plotly_enabled = True
        return plotly
    except ModuleNotFoundError:
        raise RuntimeError("plotly is not installed; plotting is disabled.") 
開發者ID:python-adaptive,項目名稱:adaptive,代碼行數:18,代碼來源:notebook_integration.py

示例4: should_update

# 需要導入模塊: import plotly [as 別名]
# 或者: from plotly import offline [as 別名]
def should_update(status):
    try:
        # Get the length of the write buffer size
        buffer_size = len(status.comm.kernel.iopub_thread._events)

        # Make sure to only keep all the messages when the notebook
        # is viewed, this means 'buffer_size == 1'. However, when not
        # viewing the notebook the buffer fills up. When this happens
        # we decide to only add messages to it when a certain probability.
        # i.e. we're offline for 12h, with an update_interval of 0.5s,
        # and without the reduced probability, we have buffer_size=86400.
        # With the correction this is np.log(86400) / np.log(1.1) = 119.2
        return 1.1 ** buffer_size * random.random() < 1
    except Exception:
        # We catch any Exception because we are using a private API.
        return True 
開發者ID:python-adaptive,項目名稱:adaptive,代碼行數:18,代碼來源:notebook_integration.py

示例5: __init__

# 需要導入模塊: import plotly [as 別名]
# 或者: from plotly import offline [as 別名]
def __init__(self, fig):
        # Create a QApplication instance or use the existing one if it exists
        self.app = QApplication.instance() if QApplication.instance() else QApplication(sys.argv)

        super().__init__()

        # This ensures there is always a reference to this widget and it doesn't get garbage collected
        global instance_list
        instance_list.append(self)

        # self.file_path = os.path.abspath(os.path.join(os.path.dirname(__file__), "temp.html"))
        self.file_path = os.path.join(os.getcwd(), 'temp.html')
        self.setWindowTitle("Plotly Viewer")

        plotly.offline.plot(fig, filename=self.file_path, auto_open=False)
        self.load(QUrl.fromLocalFile(self.file_path))

        self.resize(640, 480)
        self.show() 
開發者ID:adamerose,項目名稱:pandasgui,代碼行數:21,代碼來源:plotly_viewer.py

示例6: __init__

# 需要導入模塊: import plotly [as 別名]
# 或者: from plotly import offline [as 別名]
def __init__(self, **kwargs):
        super(VisConfig, self).__init__(**kwargs)
        self.dtype = np.float
        # Set Plotly custom variables
        self.figure_image_filename = "temp-figure"
        self.figure_image_format = "png"
        self.figure_filename = "temp-plot.html"

        # Enable online plotting (default is offline plotting as it works perfectly without any issues)
        # @see: https://plot.ly/python/getting-started/#initialization-for-online-plotting
        online_plotting = kwargs.get('online', False)

        # Detect jupyter and/or ipython environment
        try:
            get_ipython
            from plotly.offline import download_plotlyjs, init_notebook_mode
            init_notebook_mode(connected=True)
            self.plotfn = iplot if online_plotting else plotly.offline.iplot
            self.no_ipython = False
        except NameError:
            self.plotfn = plot if online_plotting else plotly.offline.plot
            self.no_ipython = True

        # Get keyword arguments
        self.display_ctrlpts = kwargs.get('ctrlpts', True)
        self.display_evalpts = kwargs.get('evalpts', True)
        self.display_bbox = kwargs.get('bbox', False)
        self.display_trims = kwargs.get('trims', True)
        self.display_legend = kwargs.get('legend', True)
        self.display_axes = kwargs.get('axes', True)
        self.axes_equal = kwargs.get('axes_equal', True)
        self.figure_size = kwargs.get('figure_size', [1024, 768])
        self.trim_size = kwargs.get('trim_size', 1)
        self.line_width = kwargs.get('line_width', 2) 
開發者ID:orbingol,項目名稱:NURBS-Python,代碼行數:36,代碼來源:VisPlotly.py

示例7: go_online

# 需要導入模塊: import plotly [as 別名]
# 或者: from plotly import offline [as 別名]
def go_online():
    """Take plotting offline."""
    pyo.__PLOTLY_OFFLINE_INITIALIZED = False 
開發者ID:plotly,項目名稱:dash-technical-charting,代碼行數:5,代碼來源:tools.py

示例8: is_offline

# 需要導入模塊: import plotly [as 別名]
# 或者: from plotly import offline [as 別名]
def is_offline():
    """Check online/offline status."""
    return pyo.__PLOTLY_OFFLINE_INITIALIZED 
開發者ID:plotly,項目名稱:dash-technical-charting,代碼行數:5,代碼來源:tools.py

示例9: get_version_one_path

# 需要導入模塊: import plotly [as 別名]
# 或者: from plotly import offline [as 別名]
def get_version_one_path() -> typing.Optional[str]:
    try:
        from plotly.offline import offline as plotly_offline
    except Exception:
        return None

    return os.path.join(
        environ.paths.clean(os.path.dirname(plotly_offline.__file__)),
        'plotly.min.js'
    ) 
開發者ID:sernst,項目名稱:cauldron,代碼行數:12,代碼來源:plotly_component.py

示例10: get_plotlyjs

# 需要導入模塊: import plotly [as 別名]
# 或者: from plotly import offline [as 別名]
def get_plotlyjs():
    path = os.path.join('offline', 'plotly.min.js')
    plotlyjs = resource_string('plotly', path).decode('utf-8')
    return plotlyjs 
開發者ID:jeanfeydy,項目名稱:lddmm-ot,代碼行數:6,代碼來源:offline.py

示例11: enable_mpl_offline

# 需要導入模塊: import plotly [as 別名]
# 或者: from plotly import offline [as 別名]
def enable_mpl_offline(resize=False, strip_style=False,
                       verbose=False, show_link=True,
                       link_text='Export to plot.ly', validate=True):
    """
    Convert mpl plots to locally hosted HTML documents.

    This function should be used with the inline matplotlib backend
    that ships with IPython that can be enabled with `%pylab inline`
    or `%matplotlib inline`. This works by adding an HTML formatter
    for Figure objects; the existing SVG/PNG formatters will remain
    enabled.

    (idea taken from `mpld3._display.enable_notebook`)

    Example:
    ```
    from plotly.offline import enable_mpl_offline
    import matplotlib.pyplot as plt

    enable_mpl_offline()

    fig = plt.figure()
    x = [10, 15, 20, 25, 30]
    y = [100, 250, 200, 150, 300]
    plt.plot(x, y, "o")
    fig
    ```
    """
    init_notebook_mode()

    ip = IPython.core.getipython.get_ipython()
    formatter = ip.display_formatter.formatters['text/html']
    formatter.for_type(matplotlib.figure.Figure,
                       lambda fig: iplot_mpl(fig, resize, strip_style, verbose,
                                             show_link, link_text, validate)) 
開發者ID:jeanfeydy,項目名稱:lddmm-ot,代碼行數:37,代碼來源:offline.py

示例12: singleBoxplot

# 需要導入模塊: import plotly [as 別名]
# 或者: from plotly import offline [as 別名]
def singleBoxplot(array):
    import plotly.express as px
    import pandas as pd
    df=pd.DataFrame(array,columns=["value"])
    fig = px.box(df, y="value",points="all")
    # fig.show() #show in Jupyter
    import plotly
    plotly.offline.plot (fig) #works in spyder

#04-split curve into continuous parts based on the jumping position 使用1維卷積的方法,在曲線跳變點切分曲線 
開發者ID:richieBao,項目名稱:python-urbanPlanning,代碼行數:12,代碼來源:showMatLabFig._spatioTemporal.py

示例13: graphMerge

# 需要導入模塊: import plotly [as 別名]
# 或者: from plotly import offline [as 別名]
def graphMerge(num_meanDis_DF):
    plt.clf()
    import plotly.express as px
    from plotly.offline import plot
    
    #01-draw scatter paring
    # coore_columns=["number","mean distance","PHMI"]
    # fig = px.scatter_matrix(num_meanDis_DF[coore_columns],width=1800, height=800)
    # # fig.show() #show in jupyter
    # plot(fig)
     
    #02-draw correlation using plt.matshow-A
    # Corrcoef=np.corrcoef(np.array(num_meanDis_DF[coore_columns]).transpose()) #sns_columns=["number","mean distance","PHMI"]
    # print(Corrcoef)
    # plt.matshow(num_meanDis_DF[coore_columns].corr())
    # plt.xticks(range(len(coore_columns)), coore_columns)
    # plt.yticks(range(len(coore_columns)), coore_columns)
    # plt.colorbar()
    # plt.show()    
    
    #03-draw correlation -B
    # Compute the correlation matrix
    # plt.clf()
    # corr_columns_b=["number","mean distance","PHMI"]
    # corr = num_meanDis_DF[corr_columns_b].corr()    
    corr = num_meanDis_DF.corr()  
    # # Generate a mask for the upper triangle
    # mask = np.triu(np.ones_like(corr, dtype=np.bool))    
    # # Set up the matplotlib figure
    # f, ax = plt.subplots(figsize=(11, 9))    
    # # Generate a custom diverging colormap
    # cmap = sns.diverging_palette(220, 10, as_cmap=True)    
    # # Draw the heatmap with the mask and correct aspect ratio
    # sns.heatmap(corr, mask=mask, cmap=cmap, vmax=.3, center=0,square=True, linewidths=.5, cbar_kws={"shrink": .5})
    
    #04
    # Draw a heatmap with the numeric values in each cell
    plt.clf()
    sns.set()
    f, ax = plt.subplots(figsize=(15, 13))
    sns.heatmap(corr, annot=True, fmt=".2f", linewidths=.5, ax=ax)
        
    #04-draw curves
    # plt.clf()
    # sns_columns=["number","mean distance","PHMI"]
    # sns.set(rc={'figure.figsize':(25,3)})
    # sns.lineplot(data=num_meanDis_DF[sns_columns], palette="tab10", linewidth=2.5)
   
#rpy2調用R編程,參考:https://rpy2.github.io/doc/v2.9.x/html/introduction.html 
開發者ID:richieBao,項目名稱:python-urbanPlanning,代碼行數:51,代碼來源:showMatLabFig._spatioTemporal.py


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