曲线函数
0.00
★7次@未来之窗
A:赛忞初雪
from manim import * class LimitGraph01(Scene): def construct(self): # 设置背景颜色为白色 self.camera.background_color = WHITE # 创建坐标轴 axes = Axes( x_range=(0, 4, 1), # x 轴范围从 0 到 4,刻度间隔为 1 y_range=(0, 4, 1), # y 轴范围从 0 到 4,刻度间隔为 1 axis_config={"color": BLUE} # 坐标轴的颜色设置为蓝色 ) # 创建函数图像 f(x)=x^2 graph = axes.plot(lambda x: x ** 2, color=BLACK, stroke_width=10) # 创建一个橙色的圆角矩形(长方形),宽度为 1,高度为 21 srounded = RoundedRectangle( corner_radius=0, # 圆角半径为 0,形成直角矩形 height=21, # 矩形高度为 21 width=1, # 矩形宽度为 1 color=ORANGE, # 矩形颜色为橙色 fill_opacity=0.5 # 填充不透明度为 0.5,使其半透明 ).move_to(axes.c2p(1.5, 7)) # 创建一个黄色的圆角矩形,宽度为 21,高度为 1 srounded2 = RoundedRectangle( corner_radius=0, # 圆角半径为 0,形成直角矩形 height=1, # 矩形高度为 1 width=21, # 矩形宽度为 21 color=YELLOW_D, # 矩形颜色为暗黄色 fill_opacity=0.5 # 填充不透明度为 0.5,使其半透明 ).move_to(axes.c2p(3.5, 2.25)) # 创建一条虚线(水平),从(0, 2.25)到(1.5, 2.25) line_a = DashedLine( axes.c2p(0, 2.25), # 起点坐标 axes.c2p(1.5, 2.25), # 终点坐标 color=manimcolor.from_hsv((0, 100, 256)), # 虚线的颜色设置(hsv 色彩空间) stroke_width=2 # 虚线宽度为 2 ) # 创建一条虚线(垂直),从(1.5, 0)到(1.5, 2.25) line_b = DashedLine( axes.c2p(1.5, 0), # 起点坐标 axes.c2p(1.5, 2.25), # 终点坐标 color=manimcolor.from_hsv((0, 100, 256)), # 虚线的颜色设置(hsv 色彩空间) stroke_width=2 # 虚线宽度为 2 ) # 创建限制值 l 标签 limit_label = MathTex("l", color=BLACK).next_to(axes.c2p(0, 2.25)).shift(0.5 * LEFT).scale(0.75) # 创建 ε 的标签,上方位置 epsilon_label = MathTex("l + \\epsilon", color=PINK).next_to(axes.c2p(0, 2.25), 2 * UP).shift(0.5 * LEFT).scale(0.75) # 创建 ε 的标签,下方位置 epsilon_minus_label = MathTex("l - \\epsilon", color=PINK).next_to(axes.c2p(0, 2.25), -2 * UP).shift(0.5 * LEFT).scale(0.75) # 创建 a 标签 a_label = MathTex("a", color=BLACK).next_to(axes.c2p(1.5, 0), DOWN).scale(0.75) # 创建 a - δ 的标签 a_minus_delta_label = MathTex("a - \\delta", color=PINK).next_to(axes.c2p(1.5, 0), DOWN).shift(LEFT).scale(0.75) # 创建 a + δ 的标签 a_plus_delta_label = MathTex("a + \\delta", color=PINK).next_to(axes.c2p(1.5, 0), DOWN).shift(RIGHT).scale(0.75) # 添加所有元素到场景中 self.add(axes, graph, srounded, srounded2, line_a, line_b) self.add(limit_label, epsilon_label, epsilon_minus_label) self.add(a_label, a_minus_delta_label, a_plus_delta_label) # 添加 f(x) 标签 f_label = MathTex("f(x)", color=BLACK).next_to(axes.c2p(1, 1), LEFT) self.add(f_label)
硬件app