Skip to content

Sillte/figpptx

Repository files navigation

figpptx

Introduction

figpptx performs conversion of artists of matplotlib to Shape Object (Powerpoint).

Suppose the situation you write a python code in order to make a presentation with PowerPoint.
I bet many use matplotlib (or the derivatives) for visualization.
We have to transfer objects of matplotlib such as Figure to Slide of Powerpoint.
It is desirable to perform this process swiftly, since we'd like to improve details of visualization based on the feel of Slide.

I considered how to perform this chore efficiently.
figpptx is written to integrate my experiments as a (somewhat) makeshift library.

Requirements

  • Python 3.6+ (My environment is 3.8.2.)
  • Microsoft PowerPoint (My environment is Microsoft PowerPoint 2016)
  • See requirements.txt.

Install

Please clone or download this repository, and please execute below.

python setup.py install 

CAUTION!

This library uses COM Object for automatic operation of Powerpoint.
Therefore, automatic operations are performed at your computer. Don't be panick!

Usage

In short, rasterize convert artists to an image while transcribe convert them to Objects of Powerpoint.

Paste the image to slide

import matplotlib.pyplot as plt
import figpptx

fig, ax = plt.subplots()
ax.plot([0, 1], [1, 0], color="C2")
figpptx.rasterize(fig)

Attempt to convert Artist to Object of Powerpoint.

import matplotlib.pyplot as plt
import figpptx

fig, ax = plt.subplots()
ax.plot([0, 1], [1, 0], color="C3")
figpptx.transcribe(fig)

Some artists are rasterized and the others are converted to Objects of PowerPoint.

import matplotlib.pyplot as plt
import figpptx

fig, ax = plt.subplots()
ax.plot([0, 1], [1, 0], color="C3")
ax.set_title("Title. This is a TextBox.", fontsize=16)
figpptx.send(fig)

For details, please see documents.

Gallery

If you would like to know difference between rasterize and transcribe, please execute below. You can see some examples.

python gallery.py

Test

Unit Test

python setup.py test

Regreesion Test

pytest
  • Tests include automatic operation of PowerPoint.
  • You must close the files of PowerPoint beforehand.

Comment and Policy

  • This library is mainly for my personal practice.
  • It is yet highly possible to change specifications.
  • transcribe is far from perfection.
  • I'd like not to pursue perfection for transcrbe.
    • I feel it takes much cost but the benefit is not so large.

About

Figure of matplotlib to PowerPoint.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages