|
|
@@ -377,7 +377,7 @@ def remove_coding(text): |
|
|
{% endif %}
|
|
|
|
|
|
{% for img in images %}
|
|
|
- .. figure:: {{ build_dir }}/{{ img.basename }}.png
|
|
|
+ .. figure:: {{ build_dir }}/{{ img.basename }}.{{ default_fmt }}
|
|
|
{% for option in options -%}
|
|
|
{{ option }}
|
|
|
{% endfor %}
|
|
|
@@ -537,17 +537,7 @@ def clear_state(plot_rcparams, close=True): |
|
|
matplotlib.rcParams.update(plot_rcparams)
|
|
|
|
|
|
|
|
|
-def render_figures(code, code_path, output_dir, output_base, context,
|
|
|
- function_name, config, context_reset=False,
|
|
|
- close_figs=False):
|
|
|
- """
|
|
|
- Run a pyplot script and save the low and high res PNGs and a PDF
|
|
|
- in *output_dir*.
|
|
|
-
|
|
|
- Save the images under *output_dir* with file names derived from
|
|
|
- *output_base*
|
|
|
- """
|
|
|
- # -- Parse format list
|
|
|
+def get_plot_formats(config):
|
|
|
default_dpi = {'png': 80, 'hires.png': 200, 'pdf': 200}
|
|
|
formats = []
|
|
|
plot_formats = config.plot_formats
|
|
|
@@ -559,14 +549,27 @@ def render_figures(code, code_path, output_dir, output_base, context, |
|
|
for fmt in plot_formats:
|
|
|
if isinstance(fmt, six.string_types):
|
|
|
if ':' in fmt:
|
|
|
- suffix,dpi = fmt.split(':')
|
|
|
+ suffix, dpi = fmt.split(':')
|
|
|
formats.append((str(suffix), int(dpi)))
|
|
|
else:
|
|
|
formats.append((fmt, default_dpi.get(fmt, 80)))
|
|
|
- elif type(fmt) in (tuple, list) and len(fmt)==2:
|
|
|
+ elif type(fmt) in (tuple, list) and len(fmt) == 2:
|
|
|
formats.append((str(fmt[0]), int(fmt[1])))
|
|
|
else:
|
|
|
raise PlotError('invalid image format "%r" in plot_formats' % fmt)
|
|
|
+ return formats
|
|
|
+
|
|
|
+
|
|
|
+def render_figures(code, code_path, output_dir, output_base, context,
|
|
|
+ function_name, config, context_reset=False,
|
|
|
+ close_figs=False):
|
|
|
+ """
|
|
|
+ Run a pyplot script and save the images in *output_dir*.
|
|
|
+
|
|
|
+ Save the images under *output_dir* with file names derived from
|
|
|
+ *output_base*
|
|
|
+ """
|
|
|
+ formats = get_plot_formats(config)
|
|
|
|
|
|
# -- Try to determine if all images already exist
|
|
|
|
|
|
@@ -666,6 +669,9 @@ def run(arguments, content, options, state_machine, state, lineno): |
|
|
config = document.settings.env.config
|
|
|
nofigs = 'nofigs' in options
|
|
|
|
|
|
+ formats = get_plot_formats(config)
|
|
|
+ default_fmt = formats[0][0]
|
|
|
+
|
|
|
options.setdefault('include-source', config.plot_include_source)
|
|
|
keep_context = 'context' in options
|
|
|
context_opt = None if not keep_context else options['context']
|
|
|
@@ -814,6 +820,7 @@ def run(arguments, content, options, state_machine, state, lineno): |
|
|
|
|
|
result = format_template(
|
|
|
config.plot_template or TEMPLATE,
|
|
|
+ default_fmt=default_fmt,
|
|
|
dest_dir=dest_dir_link,
|
|
|
build_dir=build_dir_link,
|
|
|
source_link=src_link,
|
|
|
|