save_svg_as_emf¶
- pyhelpers.store.save_svg_as_emf(path_to_svg, path_to_emf, verbose=False, inkscape_exe=None, **kwargs)[source]¶
Save a SVG file (.svg) as a EMF file (.emf).
- Parameters:
path_to_svg (str) – The path where the SVG file is located.
path_to_emf (str) – The path where the EMF file will be saved.
verbose (bool | int) – Whether to print relevant information to the console; defaults to
False
.inkscape_exe (str | None) – The path to the executable “inkscape.exe”; if
inkscape_exe=None
(default), the default installation path will be used, e.g. (on Windows) “C:\Program Files\Inkscape\bin\inkscape.exe” or “C:\Program Files\Inkscape\inkscape.exe”.kwargs – [Optional] Additional parameters for the function subprocess.run().
Examples:
>>> from pyhelpers.store import save_svg_as_emf >>> from pyhelpers.dirs import cd >>> from pyhelpers.settings import mpl_preferences >>> mpl_preferences(backend='TkAgg') >>> import matplotlib.pyplot as plt >>> x, y = (1, 1), (2, 2) >>> fig = plt.figure() >>> ax = fig.add_subplot() >>> ax.plot([x[0], y[0]], [x[1], y[1]]) >>> # from pyhelpers.store import save_figure >>> # save_figure(fig, "docs/source/_images/store-save_fig-demo.pdf", verbose=True) >>> fig.show()
The above exmaple is illustrated in Figure 12:
>>> img_dir = cd("tests\images") >>> path_to_svg = cd(img_dir, "store-save_fig-demo.svg") >>> fig.savefig(path_to_svg) # Save the figure as a .svg file >>> path_to_emf = cd(img_dir, "store-save_fig-demo.emf") >>> save_svg_as_emf(path_to_svg, path_to_emf, verbose=True) Saving the .svg file as "tests\images\store-save_fig-demo.emf" ... Done. >>> plt.close()