Skip to main content

Memes with Python's matplotlib

Project description

memeplotlib

PyPI version conda-forge version Python versions License: MIT

Memes with Python's matplotlib. Create image macro memes using matplotlib for rendering and the memegen API for template discovery.

Installation

pip:

pip install memeplotlib

conda:

conda install -c conda-forge memeplotlib

Quick Start

import 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)

Features

Functional API

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")

Object-Oriented API

from memeplotlib import Meme

# Step by step
m = Meme("buzz")
m.top("memes")
m.bottom("memes everywhere")
m.save("output.png")

# Or chained
Meme("doge").top("such code").bottom("very bug").show()

Memify Existing Plots

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")

Global Configuration

import memeplotlib as memes

memes.config.font = "comic"
memes.config.color = "yellow"
memes.config.style = "none"  # don't auto-uppercase

Template Discovery

from memeplotlib import TemplateRegistry

reg = TemplateRegistry()
results = reg.search("dog")
all_templates = reg.list_all()

Documentation

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

How It Works

  1. Templates are fetched from the memegen API (blank background images + metadata)
  2. Images are cached locally for offline reuse
  3. Text is rendered using matplotlib's text system with patheffects.Stroke for the classic outlined meme look
  4. An Impact-like font (Anton) is bundled as a fallback for systems where Impact isn't installed

Dependencies

  • matplotlib >= 3.0.0
  • requests
  • numpy
  • Pillow
  • platformdirs

Requires Python 3.10+.

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

memeplotlib-0.1.0.tar.gz (110.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

memeplotlib-0.1.0-py3-none-any.whl (101.7 kB view details)

Uploaded Python 3

File details

Details for the file memeplotlib-0.1.0.tar.gz.

File metadata

  • Download URL: memeplotlib-0.1.0.tar.gz
  • Upload date:
  • Size: 110.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for memeplotlib-0.1.0.tar.gz
Algorithm Hash digest
SHA256 273550e4c6222a3b7532de6e82f7421c61d650c70af4334f4abe9a0ee294531d
MD5 bce3d4d89beadacac618ec4ad35d747c
BLAKE2b-256 3865fc1b1a38bc513a558430df4a824ac4683696d91855aaac21d9e4b9478974

See more details on using hashes here.

Provenance

The following attestation bundles were made for memeplotlib-0.1.0.tar.gz:

Publisher: publish_pypi.yml on brianckeegan/memeplotlib

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file memeplotlib-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: memeplotlib-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 101.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for memeplotlib-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 6c538ed43993b7d5fc920726b710df21b6477ffecc81be2ce31cdf238705068b
MD5 1f1301b5a03223f948560abe5975eb10
BLAKE2b-256 e4383861f697e529f620edeecce99fb63446eaaf98a3aa1caa3ea9fe84cc3ea5

See more details on using hashes here.

Provenance

The following attestation bundles were made for memeplotlib-0.1.0-py3-none-any.whl:

Publisher: publish_pypi.yml on brianckeegan/memeplotlib

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page