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.
- Python 3.6+ (My environment is 3.8.2.)
- Microsoft PowerPoint (My environment is Microsoft PowerPoint 2016)
- See
requirements.txt
.
Please clone or download this repository, and please execute below.
python setup.py install
This library uses COM Object for automatic operation of Powerpoint.
Therefore, automatic operations are performed at your computer. Don't be panick!
In short, rasterize convert artists to an image while transcribe convert them to Objects of Powerpoint.
import matplotlib.pyplot as plt
import figpptx
fig, ax = plt.subplots()
ax.plot([0, 1], [1, 0], color="C2")
figpptx.rasterize(fig)
import matplotlib.pyplot as plt
import figpptx
fig, ax = plt.subplots()
ax.plot([0, 1], [1, 0], color="C3")
figpptx.transcribe(fig)
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.
If you would like to know difference between rasterize
and transcribe
, please execute below.
You can see some examples.
python gallery.py
python setup.py test
pytest
- Tests include automatic operation of PowerPoint.
- You must close the files of PowerPoint beforehand.
- 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.