@@ -377,7 +377,7 @@ def remove_coding(text):
377377 {% endif %}
378378
379379 {% for img in images %}
380- .. figure:: {{ build_dir }}/{{ img.basename }}.png
380+ .. figure:: {{ build_dir }}/{{ img.basename }}.{{ default_fmt }}
381381 {% for option in options -%}
382382 {{ option }}
383383 {% endfor %}
@@ -541,8 +541,7 @@ def render_figures(code, code_path, output_dir, output_base, context,
541541 function_name , config , context_reset = False ,
542542 close_figs = False ):
543543 """
544- Run a pyplot script and save the low and high res PNGs and a PDF
545- in *output_dir*.
544+ Run a pyplot script and save the images in *output_dir*.
546545
547546 Save the images under *output_dir* with file names derived from
548547 *output_base*
@@ -559,7 +558,7 @@ def render_figures(code, code_path, output_dir, output_base, context,
559558 for fmt in plot_formats :
560559 if isinstance (fmt , six .string_types ):
561560 if ':' in fmt :
562- suffix ,dpi = fmt .split (':' )
561+ suffix , dpi = fmt .split (':' )
563562 formats .append ((str (suffix ), int (dpi )))
564563 else :
565564 formats .append ((fmt , default_dpi .get (fmt , 80 )))
@@ -666,6 +665,14 @@ def run(arguments, content, options, state_machine, state, lineno):
666665 config = document .settings .env .config
667666 nofigs = 'nofigs' in options
668667
668+ plot_formats = config .plot_formats
669+ if isinstance (plot_formats , six .string_types ):
670+ # String Sphinx < 1.3, Split on , to mimic
671+ # Sphinx 1.3 and later. Sphinx 1.3 always
672+ # returns a list.
673+ plot_formats = plot_formats .split (',' )
674+ default_fmt = plot_formats [0 ][0 ]
675+
669676 options .setdefault ('include-source' , config .plot_include_source )
670677 keep_context = 'context' in options
671678 context_opt = None if not keep_context else options ['context' ]
@@ -814,6 +821,7 @@ def run(arguments, content, options, state_machine, state, lineno):
814821
815822 result = format_template (
816823 config .plot_template or TEMPLATE ,
824+ default_fmt = default_fmt ,
817825 dest_dir = dest_dir_link ,
818826 build_dir = build_dir_link ,
819827 source_link = src_link ,
0 commit comments