Skip to main content
STATANIM — Statistical Animation for Manim

PyPI version PyPI Downloads Downloads Python 3.10+ Manim Community License: MIT

A Manim extension for animated statistical visualisations.

Distributions, inference, regression, probability theory, and physical props — all built on Manim Community.


Why statanim?

Manim is extraordinary at animating mathematics — but when it comes to statistics, you're on your own. Want to show a normal distribution shading its tails as sigma changes? A probability tree that builds itself node by node? A deck of cards dealing out to demonstrate hypergeometric sampling? With vanilla Manim, each of these requires hundreds of lines of low-level geometry code before you even start on the actual statistics.

statanim closes that gap. It gives statistics the same treatment Manim gives mathematics: objects that understand what they represent, animations that carry statistical meaning, and a workflow that stays out of your way so you can focus on the idea you're trying to communicate.

Whether you're building lecture slides, making YouTube explainers, or just trying to build intuition for a concept — statanim lets you go from idea to animation in minutes, not days.


Demo

Sample Space

Sample Space

Classical Probability

Classical Probability

Conditional Probability

Conditional Probability

Hypergeometric Distribution

Hypergeometric Distribution

Birthday Paradox

Birthday Paradox


Installation

Prerequisites

pip install manim

LaTeX is required for formula rendering:

# macOS
brew install mactex-no-gui

# Ubuntu / Debian
sudo apt-get install texlive-full

# Windows: install MiKTeX from https://miktex.org/

Install statanim

pip install statanim

Install from source

git clone https://github.com/rishabhbhartiya/statanim.git
cd statanim
pip install -e .

Verify

from manim import *
from statanim.props.card import Card3D
from statanim.distributions.normal3d import NormalCurve3D
from statanim.core.colors import DARK_THEME

Quick Start

Normal distribution with shaded region

from manim import *
from statanim.distributions.normal3d import NormalCurve3D

class NormalDemo(Scene):
    def construct(self):
        curve = NormalCurve3D(mu=0, sigma=1)

        self.play(Create(curve))
        self.play(FadeIn(curve.shade_region(x_lo=-1, x_hi=1)))
        self.wait(2)

Probability with playing cards

from manim import *
from statanim.props.card import Deck3D, CardFacing, standard_deck

class CardDraw(Scene):
    def construct(self):
        deck = Deck3D(cards=standard_deck(shuffle=True, seed=0),
                      initial_facing=CardFacing.FACE_DOWN)
        deck.move_to(LEFT * 3)
        self.play(FadeIn(deck))
        self.play(deck.deal_one(target=RIGHT * 2, flip=True))
        self.wait(2)

What's Inside

Module What it gives you
distributions Normal, Binomial, Poisson, Hypergeometric, Beta, Gamma, Chi-squared, Student-t, F — all with PDF/PMF/CDF visualisers and shadeable regions
charts BarChart3D, Histogram3D, BoxPlot3D, ViolinPlot3D, HeatMap3D, ScatterPlot3D, LinePlot3D — statistically correct, 3D-aware
probability SampleSpace3D, VennDiagram3D, ProbabilityTree3D, BayesBox3D — builds event regions and conditional flows step by step
inference HypothesisRegion3D, ConfidenceInterval3D, SamplingDistribution3D, Type I/II error visualisation
regression RegressionPlane3D, ScatterCloud3D, residual diagnostics, correlation matrices, CI/PI shells
props Card3D, Deck3D, Coin3D, Die3D (D4–D20), Spinner3D, Urn3D — physical probability objects with built-in logic and animations
animations CLTDemo, DistMorph3D, ParameterSweep3D, BootstrapSampling3D, ScatterToRegression3D
ui Ticker3D, PValueTicker3D, FormulaPanel3D, DataTable3D, AnnotationArrow3D
core 6 built-in themes (DARK, LIGHT, PAPER, and more), diverging colormaps, 50+ LaTeX formula builders

Full class and parameter documentation: API_REFERENCE.md


Camera Orientation Reference

All ThreeDScene subclasses need an explicit camera orientation at the top of construct().

def construct(self):
    self.set_camera_orientation(phi=70*DEGREES, theta=-45*DEGREES)
Scene type phi theta
3D bar chart 65° -55°
Regression plane 70° -45°
Scatter cloud 70° -60°
Card grid (table-top) 60° -45°
Bivariate normal surface 68° -45°

Use Scene (not ThreeDScene) for 2D content: PDF curves, PMF bars, Venn diagrams, histograms, box plots, probability trees, and hypothesis test plots.


Development Setup

git clone https://github.com/rishabhbhartiya/statanim.git
cd statanim
python -m venv .venv
source .venv/bin/activate       # Windows: .venv\Scripts\activate
pip install -e ".[dev]"

Contributing

Issues and pull requests are welcome at github.com/rishabhbhartiya/statanim.

When adding a new distribution, inherit from BaseDistribution3D, implement pdf/pmf, cdf, mean, variance, and add a scene in scenes/demo_distributions.py.


Acknowledgements

Built on Manim Community. Statistical algorithms from SciPy and NumPy. Inspired by the mathematical animation work of 3Blue1Brown.


License

MIT License. See LICENSE for details.

Author: Rishabh Bhartiya — rishabh.bhartiya.in@gmail.com

Download files

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

Source Distribution

statanim-0.1.7.tar.gz (719.1 kB view details)

Uploaded Source

Built Distribution

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

statanim-0.1.7-py3-none-any.whl (747.4 kB view details)

Uploaded Python 3

File details

Details for the file statanim-0.1.7.tar.gz.

File metadata

  • Download URL: statanim-0.1.7.tar.gz
  • Upload date:
  • Size: 719.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/7.0.0 CPython/3.14.6

File hashes

Hashes for statanim-0.1.7.tar.gz
Algorithm Hash digest
SHA256 949408b0bd822fe90a939f366f17b19f80b746531005726c973a0e8b832074ea
MD5 19cd20b68bf2a3c9e3a147831728519e
BLAKE2b-256 3caf52595e33ffff5e5210f9a742eb77ffd9caab449694731c522667b2964a22

See more details on using hashes here.

File details

Details for the file statanim-0.1.7-py3-none-any.whl.

File metadata

  • Download URL: statanim-0.1.7-py3-none-any.whl
  • Upload date:
  • Size: 747.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/7.0.0 CPython/3.14.6

File hashes

Hashes for statanim-0.1.7-py3-none-any.whl
Algorithm Hash digest
SHA256 c412daff674ac7d8420be1423b759500ee6b3328522799c072eee8f00f8506d4
MD5 5d8810b61675d439dddb9b18ac3d9d63
BLAKE2b-256 ebae0dabeb6a5cb8d21f4f3cfd15774eb1aa7cf75387ede65ce03edbb66a0113

See more details on using hashes here.

Release history Release notifications | RSS feed

0.1.9

2 files

0.1.8

2 files

This release

0.1.7 This release

2 files

0.1.6

2 files

0.1.5

2 files

0.1.4

2 files

0.1.3

2 files

0.1.2

2 files

0.1.1

2 files

0.1.0

2 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page