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


Python scrapers.figure_rst方法代碼示例

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


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

示例1: __call__

# 需要導入模塊: from sphinx_gallery import scrapers [as 別名]
# 或者: from sphinx_gallery.scrapers import figure_rst [as 別名]
def __call__(self, block, block_vars, gallery_conf):
        """Save the figures generated after running example code.

        Called by sphinx-gallery.

        """
        try:
            from sphinx_gallery.scrapers import figure_rst
        except ImportError:
            raise ImportError('You must install `sphinx_gallery`')
        image_names = list()
        image_path_iterator = block_vars["image_path_iterator"]
        figures = pyvista.plotting._ALL_PLOTTERS
        for address, plotter in figures.items():
            fname = next(image_path_iterator)
            if hasattr(plotter, '_gif_filename'):
                # move gif to fname
                shutil.move(plotter._gif_filename, fname)
            else:
                plotter.screenshot(fname)
            image_names.append(fname)
        pyvista.close_all() # close and clear all plotters
        return figure_rst(image_names, gallery_conf["src_dir"]) 
開發者ID:pyvista,項目名稱:pyvista,代碼行數:25,代碼來源:sphinx_gallery.py

示例2: __call__

# 需要導入模塊: from sphinx_gallery import scrapers [as 別名]
# 或者: from sphinx_gallery.scrapers import figure_rst [as 別名]
def __call__(self, block, block_vars, gallery_conf):
        # Find all PNG files in the directory of this example.
        pngs = sorted(glob.glob(os.path.join(os.path.dirname(__file__), '_static/img/sphx_glr_*.png')))

        # Iterate through PNGs, copy them to the sphinx-gallery output directory
        image_names = list()
        image_path_iterator = block_vars['image_path_iterator']
        for png in pngs:
            if png not in self.seen:
                self.seen |= set(png)
                this_image_path = image_path_iterator.next()
                image_names.append(this_image_path)
                shutil.copy(png, this_image_path)
        # Use the `figure_rst` helper function to generate rST for image files
        images_rst = figure_rst(image_names, gallery_conf['src_dir'])
        return images_rst 
開發者ID:pyro-ppl,項目名稱:numpyro,代碼行數:18,代碼來源:conf.py

示例3: _alpha_mpl_scraper

# 需要導入模塊: from sphinx_gallery import scrapers [as 別名]
# 或者: from sphinx_gallery.scrapers import figure_rst [as 別名]
def _alpha_mpl_scraper(block, block_vars, gallery_conf):
    import matplotlib.pyplot as plt
    image_path_iterator = block_vars['image_path_iterator']
    image_paths = list()
    for fig_num, image_path in zip(plt.get_fignums(), image_path_iterator):
        fig = plt.figure(fig_num)
        assert image_path.endswith('.png')
        # use format that does not support alpha
        image_path = image_path[:-3] + 'jpg'
        fig.savefig(image_path)
        image_paths.append(image_path)
    plt.close('all')
    return figure_rst(image_paths, gallery_conf['src_dir']) 
開發者ID:sphinx-gallery,項目名稱:sphinx-gallery,代碼行數:15,代碼來源:test_gen_rst.py

示例4: __call__

# 需要導入模塊: from sphinx_gallery import scrapers [as 別名]
# 或者: from sphinx_gallery.scrapers import figure_rst [as 別名]
def __call__(self, block, block_vars, gallery_conf):
        """
        Called by sphinx-gallery to save the figures generated after running
        example code.
        """
        try:
            from sphinx_gallery.scrapers import figure_rst
        except ImportError:
            raise ImportError('You must install `sphinx_gallery`')
        image_names = list()
        image_path_iterator = block_vars["image_path_iterator"]
        for k, p in Plotter.DICT_PLOTTERS.items():
            fname = next(image_path_iterator)

            for _, lren in p.renderers.items():
                for r in lren:
                    for i in range(r.actors2D.n_items):
                        a = r.actors2D[i]
                        if not isinstance(a, BSScalarBarActor):
                            continue
                        a.labelTextProperty.fontsize = a.labelTextProperty.fontsize * 3

            p.screenshot(fname, scale=3)
            # p.screenshot(fname)
            image_names.append(fname)

        Plotter.close_all()  # close and clear all plotters
        return figure_rst(image_names, gallery_conf["src_dir"]) 
開發者ID:MICA-MNI,項目名稱:BrainSpace,代碼行數:30,代碼來源:sphinx_gallery_scrapper.py

示例5: __call__

# 需要導入模塊: from sphinx_gallery import scrapers [as 別名]
# 或者: from sphinx_gallery.scrapers import figure_rst [as 別名]
def __call__(self, block, block_vars, gallery_conf):
        """
        Called by sphinx-gallery to save the figures generated after running
        code.
        """
        image_names = list()
        image_path_iterator = block_vars["image_path_iterator"]
        figures = SHOWED_FIGURES
        while figures:
            fname = next(image_path_iterator)
            fig = figures.pop(0)
            fig.savefig(fname, transparent=True, dpi=200)
            image_names.append(fname)
        return figure_rst(image_names, gallery_conf["src_dir"]) 
開發者ID:GenericMappingTools,項目名稱:pygmt,代碼行數:16,代碼來源:sphinx_gallery.py


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