Memes with Python's matplotlib. Create image macro memes using matplotlib for rendering and the memegen API for template discovery.
pip:
pip install memeplotlibconda:
conda install -c conda-forge memeplotlibimport memeplotlib as memes
# One-liner meme from a memegen template
memes.meme("buzz", "memes", "memes everywhere")# Save to file
memes.meme("doge", "such code", "very bug", savefig="meme.png", show=False)import memeplotlib as memes
# Customize text styling
memes.meme("drake", "writing tests", "shipping to prod",
font="impact", color="yellow")# Get figure/axes back for further customization
fig, ax = memes.meme("distracted", "my project", "new framework", "me",
show=False)# Use a local image as template
memes.meme("/path/to/image.jpg", "top text", "bottom text")from memeplotlib import Meme
# Step by step
m = Meme("drake")
m.top("reading docs")
m.bottom("guessing until it works")
m.save("output.png")# Or chained
Meme("buzz").top("python").bottom("python everywhere").show()Turn any matplotlib figure into a meme:
import matplotlib.pyplot as plt
import memeplotlib as memes
fig, ax = plt.subplots()
ax.plot([1, 2, 3], [1, 4, 9])
memes.memify(fig, "stonks")import memeplotlib as memes
memes.config.font = "comic"
memes.config.color = "yellow"
memes.config.fontsize = 120 # base font size in points
memes.config.style = "none" # don't auto-uppercase
memes.meme("buzz", "custom defaults", "applied everywhere", show=False)from memeplotlib import TemplateRegistry
reg = TemplateRegistry()
results = reg.search("dog")
all_templates = reg.list_all()Full documentation including a tutorial, user guide, and API reference is available at brianckeegan.github.io/memeplotlib.
To build the docs locally:
pip install -e ".[docs]"
cd docs
make html
open _build/html/index.html- Templates are fetched from the memegen API (blank background images + metadata)
- Images are cached locally for offline reuse
- Text is rendered using matplotlib's text system with
patheffects.Strokefor the classic outlined meme look - An Impact-like font (Anton) is bundled as a fallback for systems where Impact isn't installed
matplotlib >= 3.0.0requestsnumpyPillowplatformdirs
Requires Python 3.10+.
MIT








