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

Function save_icon

tools/make_icons.py:39–53  ·  view source on GitHub ↗
(fig, dest_dir, name, add_black_fg_color)

Source from the content-addressed store, hash-verified

37
38
39def save_icon(fig, dest_dir, name, add_black_fg_color):
40 if add_black_fg_color:
41 # Add explicit black foreground color to monochromatic svg icons
42 # so it can be replaced by backends to add dark theme support
43 svg_bytes_io = BytesIO()
44 fig.savefig(svg_bytes_io, format='svg')
45 svg = svg_bytes_io.getvalue()
46 before, sep, after = svg.rpartition(b'\nz\n"')
47 svg = before + sep + b' style="fill:black;"' + after
48 (dest_dir / (name + '.svg')).write_bytes(svg)
49 else:
50 fig.savefig(dest_dir / (name + '.svg'))
51 fig.savefig(dest_dir / (name + '.pdf'))
52 for dpi, suffix in [(24, ''), (48, '_large')]:
53 fig.savefig(dest_dir / (name + suffix + '.png'), dpi=dpi)
54
55
56def make_icon(font_path, ccode):

Callers 1

make_iconsFunction · 0.85

Calls 1

savefigMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…