Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 838fa1f

Browse filesBrowse files
committed
Merge pull request #5677 from mdboom/docs-svg
Fix #5573: Use SVG in docs
2 parents 4573e1e + f6b15c5 commit 838fa1f
Copy full SHA for 838fa1f

File tree

Expand file treeCollapse file tree

3 files changed

+23
-16
lines changed
Filter options
Expand file treeCollapse file tree

3 files changed

+23
-16
lines changed

‎doc/conf.py

Copy file name to clipboardExpand all lines: doc/conf.py
+1-1Lines 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

Copy file name to clipboardExpand all lines: lib/matplotlib/sphinxext/plot_directive.py
+21-14Lines changed: 21 additions & 14 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 %}
@@ -537,17 +537,7 @@ def clear_state(plot_rcparams, close=True):
537537
matplotlib.rcParams.update(plot_rcparams)
538538

539539

540-
def render_figures(code, code_path, output_dir, output_base, context,
541-
function_name, config, context_reset=False,
542-
close_figs=False):
543-
"""
544-
Run a pyplot script and save the low and high res PNGs and a PDF
545-
in *output_dir*.
546-
547-
Save the images under *output_dir* with file names derived from
548-
*output_base*
549-
"""
550-
# -- Parse format list
540+
def get_plot_formats(config):
551541
default_dpi = {'png': 80, 'hires.png': 200, 'pdf': 200}
552542
formats = []
553543
plot_formats = config.plot_formats
@@ -559,14 +549,27 @@ def render_figures(code, code_path, output_dir, output_base, context,
559549
for fmt in plot_formats:
560550
if isinstance(fmt, six.string_types):
561551
if ':' in fmt:
562-
suffix,dpi = fmt.split(':')
552+
suffix, dpi = fmt.split(':')
563553
formats.append((str(suffix), int(dpi)))
564554
else:
565555
formats.append((fmt, default_dpi.get(fmt, 80)))
566-
elif type(fmt) in (tuple, list) and len(fmt)==2:
556+
elif type(fmt) in (tuple, list) and len(fmt) == 2:
567557
formats.append((str(fmt[0]), int(fmt[1])))
568558
else:
569559
raise PlotError('invalid image format "%r" in plot_formats' % fmt)
560+
return formats
561+
562+
563+
def render_figures(code, code_path, output_dir, output_base, context,
564+
function_name, config, context_reset=False,
565+
close_figs=False):
566+
"""
567+
Run a pyplot script and save the images in *output_dir*.
568+
569+
Save the images under *output_dir* with file names derived from
570+
*output_base*
571+
"""
572+
formats = get_plot_formats(config)
570573

571574
# -- Try to determine if all images already exist
572575

@@ -666,6 +669,9 @@ def run(arguments, content, options, state_machine, state, lineno):
666669
config = document.settings.env.config
667670
nofigs = 'nofigs' in options
668671

672+
formats = get_plot_formats(config)
673+
default_fmt = formats[0][0]
674+
669675
options.setdefault('include-source', config.plot_include_source)
670676
keep_context = 'context' in options
671677
context_opt = None if not keep_context else options['context']
@@ -814,6 +820,7 @@ def run(arguments, content, options, state_machine, state, lineno):
814820

815821
result = format_template(
816822
config.plot_template or TEMPLATE,
823+
default_fmt=default_fmt,
817824
dest_dir=dest_dir_link,
818825
build_dir=build_dir_link,
819826
source_link=src_link,

‎lib/matplotlib/textpath.py

Copy file name to clipboardExpand all lines: lib/matplotlib/textpath.py
+1-1Lines 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 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.