MCPcopy Index your code
hub / github.com/matplotlib/matplotlib / render_figures

Function render_figures

lib/matplotlib/sphinxext/plot_directive.py:664–781  ·  view source on GitHub ↗

Run a pyplot script and save the images in *output_dir*. Save the images under *output_dir* with file names derived from *output_base*

(code, code_path, output_dir, output_base, context,
                   function_name, config, context_reset=False,
                   close_figs=False,
                   code_includes=None)

Source from the content-addressed store, hash-verified

662
663
664def render_figures(code, code_path, output_dir, output_base, context,
665 function_name, config, context_reset=False,
666 close_figs=False,
667 code_includes=None):
668 """
669 Run a pyplot script and save the images in *output_dir*.
670
671 Save the images under *output_dir* with file names derived from
672 *output_base*
673 """
674
675 if function_name is not None:
676 output_base = f'{output_base}_{function_name}'
677 formats = get_plot_formats(config)
678
679 # Try to determine if all images already exist
680
681 is_doctest, code_pieces = _split_code_at_show(code, function_name)
682 # Look for single-figure output files first
683 img = ImageFile(output_base, output_dir)
684 for format, dpi in formats:
685 if context or out_of_date(code_path, img.filename(format),
686 includes=code_includes):
687 all_exists = False
688 break
689 img.formats.append(format)
690 else:
691 all_exists = True
692
693 if all_exists:
694 return [(code, [img])]
695
696 # Then look for multi-figure output files
697 results = []
698 for i, code_piece in enumerate(code_pieces):
699 images = []
700 for j in itertools.count():
701 if len(code_pieces) > 1:
702 img = ImageFile('%s_%02d_%02d' % (output_base, i, j),
703 output_dir)
704 else:
705 img = ImageFile('%s_%02d' % (output_base, j), output_dir)
706 for fmt, dpi in formats:
707 if context or out_of_date(code_path, img.filename(fmt),
708 includes=code_includes):
709 all_exists = False
710 break
711 img.formats.append(fmt)
712
713 # assume that if we have one, we have them all
714 if not all_exists:
715 all_exists = (j > 0)
716 break
717 images.append(img)
718 if not all_exists:
719 break
720 results.append((code_piece, images))
721 else:

Callers 1

runFunction · 0.85

Calls 14

filenameMethod · 0.95
get_plot_formatsFunction · 0.85
_split_code_at_showFunction · 0.85
ImageFileClass · 0.85
out_of_dateFunction · 0.85
clear_stateFunction · 0.85
_run_codeFunction · 0.85
_parse_srcsetFunction · 0.85
PlotErrorClass · 0.85
countMethod · 0.80
get_all_fig_managersMethod · 0.80
clearMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…