Mathematics for AI Utilities
Project description
Mathicon
Publication-ready figures for mathematics and machine learning — one import away.
Mathicon is the companion library for the Mathematics for AI book and any technical project that generates chapter figures with Python. It gives you a shared visual language: consistent colors, matrix and vector layouts, reusable icons, and mindmaps driven by JSON — so every diagram in a long manuscript looks like it belongs to the same book.
- Online Reading & Gallery: math4ai.org/mathicon/
- Platforms: Linux x86_64, Python 3.9+ (3.12 recommended). Dependencies: matplotlib, numpy.
Why Mathicon?
Writing a math or ML book means hundreds of small plotting scripts — one per figure. Without a shared toolkit, colors drift, brace styles diverge, and mindmaps become copy-paste nightmares.
Mathicon fixes that:
- One palette across linear algebra, optimization, probability, and information theory chapters
- Matrix & vector helpers — dashed rows/cols, braces, piercing highlights, affine grids, arrows
- Dozens of built-in icons for mindmaps (SVD, Bellman, KL, Langevin, EM, …)
- JSON mindmaps — declare nodes and edges; render a publication-quality figure from
mindmap.json - Local icon hooks — add a custom shape in one script without forking the library
save_figure_to_script_dir— output lands next to your script, ready for\includegraphics
Built for authors and educators who care how their PDFs look, not just that the code runs.
Installation
Install from PyPI (release wheel, Linux x86_64):
pip install mathicon
For local development setup (from source), running unit tests, or building release packages, please refer to the Developer Guide (dev.md).
What you can build
| Area | Examples |
|---|---|
| Colors | plane_color, point_x_color, normal_vector_color, … |
| Matrices | Matrix, dashed rows/cols, braces, row/column coloring |
| Vectors | draw_vec, draw_affine_grid, arrow |
| Mindmaps | render_mindmap(__file__) + mindmap.json |
| Icons | QR, LU, SVD, gradient, Bayes, Markov, score field, … |
| Icon preview | mathicon-icon-gui (Tkinter browser), mathicon-preview-icons (CLI export) |
| Figures | save_figure_to_script_dir, 2D/3D grid styling, math fonts |
A minute of code
Consistent scatter plot
from mathicon import point_x_color, save_figure_to_script_dir
import matplotlib.pyplot as plt
fig, ax = plt.subplots()
ax.scatter([1, 2, 3], [1, 4, 9], color=point_x_color)
save_figure_to_script_dir("example.png")
Mindmap from JSON
from mathicon import render_mindmap
if __name__ == "__main__":
render_mindmap(__file__) # reads mindmap.json beside this script
Custom mindmap icon (local hook)
def draw_my_topic_icon(ax, center_x, center_y, size=0.5):
...
Reference "icon": "my_topic" in mindmap.json — no library patch required.
Preview icons (Tkinter GUI)
Browse every built-in icon interactively — search by name, filter by category, view static and animated previews, and export PNG or GIF:
mathicon-icon-gui
Requires a graphical session (X11 or Wayland on Linux; install python3-tk if Tkinter is missing). For headless batch export to ./preview/, use mathicon-preview-icons instead:
mathicon-preview-icons --list
mathicon-preview-icons basis_dim rotation svd --format png
Who is it for?
- Authors of textbooks and monographs with matplotlib figure pipelines
- Course materials that need repeatable, professional diagrams
- Researchers publishing papers who want book-grade consistency across chapters
Install once, import everywhere your scripts live.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
Built Distributions
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file mathicon-1.0.0-cp313-cp313-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl.
File metadata
- Download URL: mathicon-1.0.0-cp313-cp313-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
- Upload date:
- Size: 108.5 kB
- Tags: CPython 3.13, manylinux: glibc 2.17+ x86-64, manylinux: glibc 2.28+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ee5c274f777ee25cde0d48484f7e255ea9ab3bf85c3de8a2905987ba4e49c77d
|
|
| MD5 |
6b871704bf88dfd0ccdc8dcb67a372f9
|
|
| BLAKE2b-256 |
49439bd481930e6196d021c3afce273bd75db3e99ea3bd0f3368553e2a00b907
|
File details
Details for the file mathicon-1.0.0-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl.
File metadata
- Download URL: mathicon-1.0.0-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
- Upload date:
- Size: 93.9 kB
- Tags: CPython 3.12, manylinux: glibc 2.17+ x86-64, manylinux: glibc 2.28+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c76531359de37214a560fb9d2362349d69a0cb8a26f5a3e58668652b851a869d
|
|
| MD5 |
681c5dab3083a99e2944901b4fa9b27c
|
|
| BLAKE2b-256 |
ac7128b3c9eed990b701ba45d2901da29e8dbc3bd9b610320acf1aab471bd623
|
File details
Details for the file mathicon-1.0.0-cp311-cp311-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl.
File metadata
- Download URL: mathicon-1.0.0-cp311-cp311-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
- Upload date:
- Size: 113.1 kB
- Tags: CPython 3.11, manylinux: glibc 2.17+ x86-64, manylinux: glibc 2.28+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e2f794b9546845e51329380b982f5223dba337197db7949d3821894f87a52f25
|
|
| MD5 |
7d17a5331b6bac2bc2365ee20f7982b5
|
|
| BLAKE2b-256 |
ee01137f08933415a7c2500fbcdd0f5d987c9b4501faefdda7c1f4166bfee5c6
|
File details
Details for the file mathicon-1.0.0-cp310-cp310-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl.
File metadata
- Download URL: mathicon-1.0.0-cp310-cp310-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
- Upload date:
- Size: 79.9 kB
- Tags: CPython 3.10, manylinux: glibc 2.17+ x86-64, manylinux: glibc 2.28+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2e18448b929c8108003fdc78c9b2c212712727c14a7ee13166eda7f3714168d0
|
|
| MD5 |
ee19c9a4cc47992da1d387447ce897f4
|
|
| BLAKE2b-256 |
7c7f70f1e9878728dd7bce4ac216dc0d3a4b32d18809b6a0a6145d399d93f2c5
|
File details
Details for the file mathicon-1.0.0-cp39-cp39-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl.
File metadata
- Download URL: mathicon-1.0.0-cp39-cp39-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
- Upload date:
- Size: 78.7 kB
- Tags: CPython 3.9, manylinux: glibc 2.17+ x86-64, manylinux: glibc 2.28+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
bf2ee7c02c5feb9dd072cbf99fd30613856586f5ee2a8e4d9b4d33f69668b1bc
|
|
| MD5 |
1e958e5e84a91fe32855fd969c545ec5
|
|
| BLAKE2b-256 |
d69a4c53b957db21f6bec99580f66536415b30ddd863b51f875407ea0d43608e
|