A scene for plotting / graphing functions.
Examples
class FunctionPlotWithLabelledYAxis(GraphScene):
def __init__(self, **kwargs):
GraphScene.__init__(
self,
y_min=0,
y_max=100,
y_axis_config={"tick_frequency": 10},
y_labeled_nums=np.arange(0, 100, 10),
**kwargs
)
def construct(self):
self.setup_axes()
dot = Dot().move_to(self.coords_to_point(PI / 2, 20))
func_graph = self.get_graph(lambda x: 20 * np.sin(x))
self.add(dot,func_graph)
amp = 5
mu = 3
sig = 1
def gaussian(x):
return amp * np.exp((-1 / 2 * ((x - mu) / sig) ** 2))
class GaussianFunctionPlot(GraphScene):
def construct(self):
self.setup_axes()
graph = self.get_graph(gaussian, x_min=-1, x_max=10)
graph.set_stroke(width=5)
self.add(graph)
Classes