This joke works because plot means to draw a graph to visualize information, but it also means to scheme, to plan evil, to hatch a sinister plot. The joke works because a math teacher can plot a graph, which could be involved in plotting a crime, but not usually, which makes the speaker seem suspicious, and in a silly way, as if the plan of the graph could be the plan of a crime simply because the word plot is used to say both. It is possible our math teacher is planning a bank heist, with the suspicious graph. The math teacher is certainly plotting something, the graph, and what is normal isn’t suspicious. This shows us the word plot is used by us in two ways, and the difference is fear, suspicion that a plan is more than a plan, it is a plan for evil, and we brace for evil with fear. A plan is someone being calm and resolute in a way, and a sinister plot is a plan, a resolution, that others fear. The turn from a calm, normal, plotted mathematical situation to unreasonable paranoia and aggression is the jerk of the joke. If we look at language use in particular situations from a pragmatic perspective, and keep an eye on the situation of emotions, and how emotions can change, we can understand what jerks us around and makes us laugh at some jokes and not others.