Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 43c66e1

Browse files
committed
Fix #5573: Use SVG in docs
1 parent 5904e2f commit 43c66e1

File tree

3 files changed

+14
-6
lines changed

3 files changed

+14
-6
lines changed

doc/conf.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@
114114
# Plot directive configuration
115115
# ----------------------------
116116

117-
plot_formats = [('png', 80), ('hires.png', 200), ('pdf', 50)]
117+
plot_formats = [('svg', 72), ('png', 80)]
118118

119119
# Subdirectories in 'examples/' directory of package and titles for gallery
120120
mpl_example_sections = (

lib/matplotlib/sphinxext/plot_directive.py

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -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,

lib/matplotlib/textpath.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -343,7 +343,7 @@ def get_glyphs_tex(self, prop, s, glyph_map=None,
343343
1094995778)]:
344344
try:
345345
font.select_charmap(charmap_code)
346-
except ValueError:
346+
except (ValueError, RuntimeError):
347347
pass
348348
else:
349349
break

0 commit comments

Comments
 (0)