Files
dsProject/dsLightRag/Manim/L5_GraphingMovement.py
2025-08-14 15:45:08 +08:00

46 lines
1.4 KiB
Python
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

from manim import *
import manim
class GraphingMovement(Scene):
def construct(self):
# 修正1使用新版坐标轴配置方式
axes = Axes(
x_range=[0, 5, 1],
y_range=[0, 3, 1],
axis_config={
"tip_shape": ArrowTriangleFilledTip, # 替代include_tips
"exclude_origin_tick": True # 替代numbers_to_exclude
}
).add_coordinates()
axes.to_edge(UR)
# 修正2使用新版标签获取方式
axis_labels = axes.get_axis_labels(
Text("x").scale(0.7), # 使用Text代替x_label参数
Text("f(x)").scale(0.7)
)
graph = axes.plot(lambda x: x ** 0.5, color=YELLOW) # 使用plot方法
graphing_stuff = VGroup(axes, graph, axis_labels)
# 修正3分步创建动画
self.play(
Create(axes, run_time=2), # 新版使用Create代替DrawBorderThenFill
Write(axis_labels)
)
self.play(Create(graph))
self.play(graphing_stuff.animate.shift(DOWN * 4), run_time=3)
self.play(axes.animate.shift(LEFT * 3), run_time=3)
if __name__ == '__main__':
config = {
"quality": "low_quality",
"preview": True,
"media_dir": "./custom_output"
}
with manim.tempconfig(config):
scene = GraphingMovement()
scene.render()