Skip to main content

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.

Works on 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.


Get started

From PyPI (release wheel, Linux x86_64):

pip install mathicon

From source (editable dev install):

git clone https://github.com/xuanxinjushi/mathicon.git mathicon
cd mathicon
pip install -e ".[dev]"

Run tests:

pytest
# or: make test

Quick check:

python -c "from mathicon import plane_color; print(plane_color)"   # blue

Docker

Build image:

docker build -t mathicon:dev .

Run tests in container:

docker run --rm mathicon:dev

Generate docs icon gallery from container into local repo:

docker run --rm -v "$PWD":/app -w /app mathicon:dev make docs-icons

Open generated gallery at docs/icons.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, …
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.


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


Download files

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

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distributions

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

mathicon-0.0.1.dev0-cp313-cp313-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl (279.6 kB view details)

Uploaded CPython 3.13manylinux: glibc 2.17+ x86-64manylinux: glibc 2.28+ x86-64

mathicon-0.0.1.dev0-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl (268.3 kB view details)

Uploaded CPython 3.12manylinux: glibc 2.17+ x86-64manylinux: glibc 2.28+ x86-64

mathicon-0.0.1.dev0-cp311-cp311-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl (293.6 kB view details)

Uploaded CPython 3.11manylinux: glibc 2.17+ x86-64manylinux: glibc 2.28+ x86-64

mathicon-0.0.1.dev0-cp310-cp310-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl (195.6 kB view details)

Uploaded CPython 3.10manylinux: glibc 2.17+ x86-64manylinux: glibc 2.28+ x86-64

mathicon-0.0.1.dev0-cp39-cp39-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl (193.7 kB view details)

Uploaded CPython 3.9manylinux: glibc 2.17+ x86-64manylinux: glibc 2.28+ x86-64

File details

Details for the file mathicon-0.0.1.dev0-cp313-cp313-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for mathicon-0.0.1.dev0-cp313-cp313-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 9c9f600e26df6dd36395ba70b2a550d90c00aeb90957a7a08f9fca73d85b5afa
MD5 013530c9473638bce65c6dfdb16f5aeb
BLAKE2b-256 f7b71539ca2b960a3e1ab465e7859a5c8a73920825c47fea3472ead4702d8694

See more details on using hashes here.

File details

Details for the file mathicon-0.0.1.dev0-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for mathicon-0.0.1.dev0-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 039d729c619569a8a2b0573f4ecc7a98a9d6b50703fd75a274339375c32d3dba
MD5 59db2fd9ee78db05c97cb02f955716b9
BLAKE2b-256 20d93655515ced76f8c3bb25fd79f7ac5ea372dbfa9bf10822f44132a595251a

See more details on using hashes here.

File details

Details for the file mathicon-0.0.1.dev0-cp311-cp311-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for mathicon-0.0.1.dev0-cp311-cp311-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 95140634bc7273fec1b0106597b7fff2351cb92c8b8ddf9313d156d257272df7
MD5 538f4fbd14fc625853f9aa450ad24e3a
BLAKE2b-256 6aa075ca0eba389080d9ad2da968e18872efbaa311c571fc908522f780062c40

See more details on using hashes here.

File details

Details for the file mathicon-0.0.1.dev0-cp310-cp310-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for mathicon-0.0.1.dev0-cp310-cp310-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 a4fd70331a5fcf5fe138c8e68183cfb61e845676773cd3c8541f173e14e87558
MD5 a1ed15ec5835912434d3f3b9f7732d3a
BLAKE2b-256 ad364ec8b2385aba9f6098ffd2ce6a542b71f6f3f8f86c8b191520e15954c14b

See more details on using hashes here.

File details

Details for the file mathicon-0.0.1.dev0-cp39-cp39-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for mathicon-0.0.1.dev0-cp39-cp39-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 2be41a845669ff0907935cd64963bc957050b35b355d05d6242721b973343e14
MD5 4ebbcd7c88fb32faa0568cb0cd945c54
BLAKE2b-256 7656c952d120c978f37a94802a1fdc9a324c043a629298facc9f0c3b961ff7c3

See more details on using hashes here.

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