Graphs are created using bezier curves, bezier curves cannot be discontinuous, therefore, you must create multiple graphs for each domain you want to use.
class AddingDomains(GraphScene):
CONFIG = {
"y_max" : 5,
"y_min" : -5,
"x_max" : 6,
"x_min" : -6,
"graph_origin": ORIGIN,
}
def construct(self):
self.setup_axes()
graph_left = self.get_graph(lambda x : 1/x,
color = GREEN,
x_min = self.x_min,
x_max = 1/self.y_min
)
graph_right = self.get_graph(lambda x : 1/x,
color = GREEN,
x_min = 1/self.y_max,
x_max = self.x_max
)
graph=VGroup(graph_left,graph_right)
self.play(
ShowCreation(graph),
run_time = 2,
rate_func= double_smooth
)
self.wait()
Or
class AddingDomains2(GraphScene):
CONFIG = {
"y_max" : 5,
"y_min" : -5,
"x_max" : 6,
"x_min" : -6,
"graph_origin": ORIGIN,
}
def construct(self):
self.setup_axes()
graph_left = self.get_graph(lambda x : 1/x,
color = GREEN,
x_min = self.x_min,
x_max = 1/self.y_min
)
graph_right = self.get_graph(lambda x : 1/x,
color = GREEN,
x_min = 1/self.y_max,
x_max = self.x_max
)
graph=VMobject(color=RED)
graph.append_points(graph_left.points)
graph.append_points(graph_right.points)
self.play(
ShowCreation(graph),
run_time = 2,
rate_func= double_smooth
)
self.wait()
Returns:
More information in manimlib/mobject/types/vectorized_mobject.py and manimlib/mobject/functions.py.