Manim is a Python library that makes visualizing mathematical concepts aesthetically possible in a manageable timeframe. You describe text in markdown or latex and draw objects from primitives like circles and rectangles. The centerpiece is the abstract VMObject class from which new classes you define for drawing should inherit. The libraries biggest strength is doing all the necessary things like translating, in-/out fadinging and turning one object into another via frame by frame interpolation, a beautiful way.
Below is a short video about the isodata thresholding algorithm. It segments a picture into fore- and background by finding a threshold q iteratively for which grayscale values below are considered foreground and above background. The code for the video can be found here.