Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@ Features
import catplotlib.catplot as clt
clt.plot(says='matplotlib + cats = catplotlib')

* And, a third::

import catplotlib.catplot as clt
clt.catterplot()

Making a Release
----------------
Expand Down
39 changes: 35 additions & 4 deletions catplotlib/catplot.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
"""Top-level package for catplotlib."""

import matplotlib.pyplot as plt
import requests

import random
import sys
from io import BytesIO
from urllib.parse import quote

import matplotlib
import matplotlib.pyplot as plt
import requests

CATS = ["🐱", "😹", "😻", "🙀", "😿", "😽", "😸", "😺", "😾", "😼"]
DEFAULT_BACKEND = matplotlib.get_backend()
URL = "https://cataas.com/cat"


Expand Down Expand Up @@ -34,3 +37,31 @@ def plot(says=None):
img = plt.imread(data, format="jpg")

return plt.imshow(img)


def catterplot(n=10):
cats = CATS

x = [random.random() * 10 for _ in range(n)]
y = [random.random() * 10 for _ in range(n)]
markers = random.choices(cats, k=n)
scatter = plt.scatter(x, y, color="white")

matplotlib.use("module://mplcairo.macosx")
print(f"Backend is now {matplotlib.get_backend()}")

prop = matplotlib.font_manager.FontProperties(
fname="/System/Library/Fonts/Apple Color Emoji.ttc"
)
for x0, y0, cat in zip(x, y, markers):
plt.annotate(
cat, (x0, y0), ha="center", va="bottom", fontsize=30, fontproperties=prop
)

plt.title("Catterplot")
plt.xlabel("x-catxis")
plt.ylabel("y-catxis")
plt.xlim(min(x) - 3, max(x) + 3)
plt.ylim(min(y) - 3, max(y) + 3)

return scatter
1 change: 1 addition & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@

requirements = [
"matplotlib",
"mplcairo",
"requests",
]

Expand Down