Lazy on demand subplots.
- 1️⃣ You can draw subplots, wherever and whenever you want.
- 2️⃣ You can access mosaic subplots with Regex.
- 3️⃣ Oekaki warn about potentially misleading graphs. (No labels or units.) This feature can be ignored.
- 🍣 (Oekaki imports
japanize-matplotlib
if it's installed.)
import numpy as np
import oekaki
# 1️⃣: lazy draw subplots
fig = oekaki.figure(tight_layout=True)
# 2️⃣: able to use regex search
fig["left"].set(facecolor="black")
fig["upper"].grid(True)
# 🍣 japanize
fig["lower right"].set(aspect="equal", title="俺流 matplotlib")
theta = np.linspace(0, np.pi, 300)
r = np.abs(np.tan(theta))**(1 / np.abs(np.tan(theta)))
fig["lower right"].fill(r * np.cos(theta), r * np.sin(theta), color="#2ce62c")
fig.show("""upper left | upper right
lower left | lower right""")
3️⃣: This code raises the following warnings.
example/readme.py:12: MisleadingWarning:
lower right: No x-label.
lower right: No y-label.
fig.show("""upper left | upper right
pip install oekaki
If you want to also install japanize-matplotlib, run below.
pip install "oekaki[ja]"
First, create a figure instance.
fig = oekaki.figure()
You can use all matplotlib's Axes API.
fig["plot"].plot(x, y)
You can also use some seaborn API through sns
property. They must have ax
argument.
fig["hist"].sns.histplot(data=data)
It is also possible to manipulate the subplots using regex. (This is implemented using re.Pattern.search.)
# `.*` means ALL
fig[".*"].grid(True)
Finally, let's draw it in (enhanced) Mosaic format!
fig.show("""hist | plot""")
fig.show("""hist
plot""")
Under construction.
Under construction.
Under construction.