Best way to create vector graphics in python for use in word / powerpoint

I usually save my graphics in python as PNG. This works great, but has obvious flaws when it comes to re-scaling. Therefore, I want to save my graphics, drawings, etc. As vector graphics, then import them into Windows applications such as a word or powerpoint.

Now I am facing several problems.

  • Saving something from matplotlib as vector graphics support (SVG) works fine. The problem is, I cannot (easily) import it into a word or pp.
  • Saving as EPS gives a terrible result. For example, I have shaded areas between two lines (using fill_between with alpha 0.3), and in EPS these areas are completely colored. Import to word / pp works, but the graphics are not good.
  • I also tried to convert SVG files to EPS using inkscape. Here, the shaded areas are still preserved, but the overall quality is again not good (it looks more like bad raster graphics), and some legends are cropped.

Here are some images that try to visualize my problem.

plot saved as PNG after importing into word - the way it should look

plot saved as EPS after importing into word - no shading, ax labels and no legend (not shown)

plot saved as SVG and then converted to EPS using inkscape after importing into word - shading correct, but all writing (labels, title etc.) in poor quality, looks actually more like a bad raster graphic

+6
source share
2 answers

Which version of Office do you use on Windows or Mac?

And in general: using EPS with Office is a kind of business. Office does not handle EPS in any standard way. If you will always print on a PostScript printer or use some other PostScript-based output method (for example, printing to PS and then relocating to PDF). EPS can work very well if you make a registry change to tell PPT (I don’t know about Word) to behave correctly. Ask and I will see if I can dig out the details. Otherwise, he tries to interpret the PS content of the EPS itself and may or may not do a good job.

Can you convert to EMF (assuming Windows is here)? And if not, can you control the resolution of your images? You can get the best results by switching to a higher resolution PNG.

0
source

Windows now seems to provide good support for embedding most PDF files as vector files and preserve vector features when exporting to PDF. This is based on my experience using Office 2011 for Mac, but it should extend to MS Office 2007 for Windows. I save my matplotlib graph as a PDF, import it into a Word document and can save it as vector output.

One catch: if you paste a PDF inside a text box, Word will rasterize it when you save it to a PDF.

For more advanced vector support, try OpenOffice - I believe that it supports direct import of SVG, albeit with some errors.

0
source

Source: https://habr.com/ru/post/975479/