A lattice of short segments carrying the slope of y' = x - y at each sample point, with one solution curve integrated through them by Runge-Kutta from a marked start on the left edge. The loop runs that start up and down the edge in one period, so the solution rethreads the field live and every curve in the family gets traced.
manim/slope_field.py
"""Slope field: y' = x - y, with one solution rethreading itself as it starts higher or lower.
Render (the driver does this for every palette; these are for eyeballing):
P=/opt/homebrew/opt/python@3.11/bin/python3.11
ASSET_MODE=still $P -m manim -s -t -r 1600,1600 manim/slope_field.py SlopeField
ASSET_MODE=motion $P -m manim -qh -r 1600,1600 manim/slope_field.py SlopeFieldLoop
"""
import numpy as np
from manim import (
DOWN,
LEFT,
TAU,
UP,
Dot,
Line,
The full Manim source and the rendered video come with a plan.