本文整理汇总了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"])
示例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
示例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'])
示例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"])
示例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"])