Skip to content

How to add vector (from matplotlib) graphics? #244

Open

Description

@richard-moss

Hi all,

great package! I've been looking for something like this for a week or so.

I was wondering what's the best way (or is there a way?) of including graphs produced by matplotlib as vector graphics (rather than bitmap like png or jpg)?

I want to put together some reports using the module, and include some graphs. I can include them fine right now using InlineImage() if I save them as jpg or png.

However due to the size impact on the resulting file (and poor resolution if printing) I'd prefer to do that in a vector format (svg, or pdf?).

I tried both pdf and svg with InlineImage() and it failed (I read issue #651 from python-docx about SVG support in python-docx).

So I was wondering is it possible, and how to go about, including matplotlib plots in a vector form?

thanks,
Richard

Activity

  1. elapouya commented on Dec 28, 2019

    @elapouya
    Owner

    This has to be developped : mark this as enhancement

  2. cvas22 commented on Nov 25, 2026

    @cvas22

    @richard-moss python-docx only embeds bitmaps, so vector formats can't go through InlineImage. A high-dpi PNG is the practical workaround.

    I'm keeping track of these in docform, the maintained fork of python-docx-template, if you want to follow up there.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions