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

5 months ago
from manim import *
5 months ago
import manim
5 months ago
class GraphingMovement(Scene):
5 months ago
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)
5 months ago
if __name__ == '__main__':
config = {
5 months ago
"quality": "low_quality",
"preview": True,
"media_dir": "./custom_output"
5 months ago
}
with manim.tempconfig(config):
scene = GraphingMovement()
scene.render()