Value Tracker Graph

Published: 27 October 2021
on channel: Flesmyn Academy
160
4

from manim import *


class ValueTrackerExample(Scene):
def construct(self):
setup graph
axes = Axes()
m_tracker = ValueTracker(1)
func = lambda m: lambda x: m * x - 1
graph = VMobject()
graph_kwargs = {"color": GREEN}

setup formula
decimal = DecimalNumber(1, num_decimal_places=1)
formula = MathTex("y = ", "x + 1")

arrange position of formula
formula.move_to(LEFT * 3 + UP)
formula[0].shift(LEFT * 1.1)
decimal.next_to(formula[0],RIGHT,aligned_edge=DOWN)

set updaters
def update_graph(mob):
mob.become(
axes.get_graph(
func(m_tracker.get_value()),
**graph_kwargs
)
)

set initial state of graph
update_graph(graph)
graph.add_updater(update_graph)

self.add(axes)

self.play(Create(graph), Write(VGroup(formula[0],decimal,formula[1])))
self.play(
m_tracker.animate.set_value(5), ChangeDecimalToValue(decimal,5)
)
self.wait()

self.play(
m_tracker.animate.set_value(-5), ChangeDecimalToValue(decimal,-5)
)
self.wait()


Watch video Value Tracker Graph online without registration, duration hours minute second in high quality. This video was added by user Flesmyn Academy 27 October 2021, don't forget to share it with your friends and acquaintances, it has been viewed on our site 160 once and liked it 4 people.