Opus Motion ★ Star on GitHub

Data · function-plot

Function plot (curve, tangent, area)

Maths-explainer plot on dark slate: axes draw on, a curve from a safe expression string traces left to right with a glowing head, a tangent (or a secant that shrinks into the tangent) slides along it with a slope readout, then Riemann bars melt into a filled area with a running integral.

A free, MIT-licensed animated chart from the Opus Motion Library — 616 motions for Remotion, React and plain HTML.

Function plot (curve, tangent, area): three frames of the animated chart, start, middle and end
Function plot (curve, tangent, area) — start, middle and end of the 8.0-second motion.

What Function plot (curve, tangent, area) is for

Maths and physics teaching, finance curves, "explain the formula" and derivative / integral explainers.

  • graph
  • plot
  • function
  • math
  • maths
  • calculus
  • derivative
  • tangent
  • integral
  • area under curve
  • axes
  • explainer
  • education
  • physics
  • 3b1b
  • formula
  • riemann
  • curve

Details

Category
Animated charts & data visualisation
Length
8.0 s (240 frames at 30 fps)
Formats
16:9, 1:1, 9:16
Weight
light
Transparent overlay
no
Seamless loop
no
Text props
title xLabel yLabel
Colour props
background ink curveColor tangentColor areaColor
Mood
night
Roles
subject

Use Function plot (curve, tangent, area) in Remotion, React or HTML

Remotion project

terminal
# copy this motion into your Remotion project
node cli/mgl.mjs add function-plot --to ../my-app/src

# render an mp4 (run in the library folder)
node cli/mgl.mjs render function-plot --props '{"title":"f(x) = sin x + x/3","xLabel":"x","yLabel":"f(x)","background":"#1C1C1C","ink":"#F2F2F2","curveColor":"#58C4DD","tangentColor":"#FFFF00","areaColor":"#83C167"}'

# or export for apps / editors: mp4 | webm-alpha | prores-alpha | gif | png | poster
node cli/mgl.mjs export function-plot --as mp4 --props '{"title":"f(x) = sin x + x/3","xLabel":"x","yLabel":"f(x)","background":"#1C1C1C","ink":"#F2F2F2","curveColor":"#58C4DD","tangentColor":"#FFFF00","areaColor":"#83C167"}'

React / Next.js

tsx
import {MotionPlayer} from 'opus-motion-library/web';

<MotionPlayer
  motion="function-plot"
  props={{
    title: 'f(x) = sin x + x/3',
    xLabel: 'x',
    yLabel: 'f(x)',
    background: '#1C1C1C',
    ink: '#F2F2F2',
    curveColor: '#58C4DD',
    tangentColor: '#FFFF00',
    areaColor: '#83C167',
  }}
  playOnView
  loop="auto"
/>

Plain HTML / WordPress

html
<script src="opus-motion.element.js" defer></script>

<opus-motion motion="function-plot"
  props='{"title":"f(x) = sin x + x/3","xLabel":"x","yLabel":"f(x)","background":"#1C1C1C","ink":"#F2F2F2","curveColor":"#58C4DD","tangentColor":"#FFFF00","areaColor":"#83C167"}'>
</opus-motion>

Compose spec (multi-scene video)

json
{
  "width": 1920,
  "height": 1080,
  "fps": 30,
  "scenes": [
    {
      "motion": "function-plot",
      "props": {
        "title": "f(x) = sin x + x/3",
        "xLabel": "x",
        "yLabel": "f(x)",
        "background": "#1C1C1C",
        "ink": "#F2F2F2",
        "curveColor": "#58C4DD",
        "tangentColor": "#FFFF00",
        "areaColor": "#83C167"
      }
    }
  ]
}

Function plot (curve, tangent, area) props

18 parameters — change any of them to make the motion yours.

PropDefaultWhat it does
fn"sin(x) + x/3"expression in x: + - * / ^, sin cos tan exp ln sqrt abs, pi, e, implicit "2x"
points[]optional [[x,y],...] data instead of fn (linearly interpolated)
domain[-6,6]x range [min, max]
rangenully range [min, max]; null = auto from the curve
tangentMode"secant"'tangent' | 'secant' (shrinking h) | 'none'
tangentFrom-4.6x where the tangent starts sliding
tangentTo3.2x where it stops
fillArea[-1,4][a, b] integral to fill, or null for none
riemann10number of Riemann bars that melt into the area (0 = none)
title"f(x) = sin x + x/3"formula caption (top left)
xLabel"x"x axis label
yLabel"f(x)"y axis label
showGridtruefaint grid
background"#1C1C1C"background colour
ink"#F2F2F2"axes / text colour
curveColor"#58C4DD"curve colour
tangentColor"#FFFF00"tangent / readout colour
areaColor"#83C167"area colour

Notes & credits

Technique sources:

  • prompt-corpus research: function-plot (16 cases, ideas only; original implementation)