You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

46 lines
1.4 KiB

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

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()