save_svg_as_emf
- pyhelpers.store.save_svg_as_emf(path_to_svg, path_to_emf, verbose=False, inkscape_exe=None, **kwargs)
Save a SVG file (.svg) as a EMF file (.emf).
- Parameters
path_to_svg (str) – path where a .svg file is saved
path_to_emf (str) – path where a .emf file is saved
verbose (bool or int) – whether to print relevant information in console, defaults to
False
inkscape_exe (str or None) – absolute path to ‘inkscape.exe’, defaults to
None
; wheninkscape_exe=None
, use the default installation path, e.g. (on Windows) “C:\Program Files\Inkscape\bin\inkscape.exe” or “C:\Program Files\Inkscape\inkscape.exe”kwargs – [optional] parameters of subprocess.run
Examples:
>>> from pyhelpers.store import save_svg_as_emf >>> from pyhelpers.dirs import cd >>> from pyhelpers.settings import mpl_preferences >>> import matplotlib.pyplot as plt >>> mpl_preferences() >>> x, y = (1, 1), (2, 2) >>> plt.figure() >>> plt.plot([x[0], y[0]], [x[1], y[1]]) >>> plt.show()
The above exmaple is illustrated in Fig. 8:
Fig. 8 An example figure created for the function
save_svg_as_emf()
.>>> img_dir = cd("tests\images") >>> svg_file_pathname = cd(img_dir, "store-save_fig-demo.svg") >>> plt.savefig(svg_file_pathname) # Save the figure as a .svg file >>> emf_file_pathname = cd(img_dir, "store-save_fig-demo.emf") >>> save_svg_as_emf(svg_file_pathname, emf_file_pathname, verbose=True) Saving the .svg file as "tests\images\store-save_fig-demo.emf" ... Done. >>> plt.close()