我正在学习使用3blue1brown的Manim,它真的很酷。我正在网上学习一些教程,想了解一下绳子,但我遇到了一个问题
from manimlib import *
import numpy as np
class Anim4 (Scene):
def construct(self):
axes = Axes(x_range = [0, 5, 1], y_range= [0, 3, 1],
x_length= 5, y_length=3,
axis_config = {"include tip": True, "numbers_to_exclude": [0]}
).add_coordinates()
axes.to_edge(UR)
axis_labels = axes.get_axis_labels(x_label = "x", y_label = "f(x)")
graph = axes.get_graph(lambda x : x**0.5, x_range = [0, 4], color =
YELLOW)
graphing_stuff = VGroup(axes, graph, axis_labels)
self.play(DrawBorderThenFill(axes), Write(axis_labels))
self.play(Create(graph))
self.play(graphing_stuff.animate.shift(DOWN*4))
self.play(axes.animate.shift(LEFT*3), RUN_TIME = 3)2问题。它没有识别Create函数,它显示了一个错误:
Axes对象没有属性“add_coordinates”
我不知道出了什么问题。
代码有变化吗?还是我不知道的事情?这些功能还存在吗?
发布于 2021-11-23 14:19:35
问题是,您复制了使用manim库的代码,并且正在导入manimlib (manim和manimlib互不兼容)。您可以安装那个版本的manim,而不使用manimlib,也可以将函数更改为manimlib中的函数。
from manimlib import *
import numpy as np
class Anim4 (Scene):
def construct(self):
axes = Axes((-5, 5), (-1, 9))
axes.add_coordinate_labels() #change axes.add_coordinate for axes.add_coordinate_labels
axes.to_edge(UR)
axes.add(axes.get_axis_labels(x_label_tex="x",y_label_tex="f(x)")) #add "axes.add"
graph = axes.get_graph(lambda x : x**0.5, x_range = [0, 4], color =
YELLOW)
graphing_stuff = VGroup(axes, graph)
self.play(DrawBorderThenFill(axes))
self.play(ShowCreation(graph)) # Change "Create" for "ShowCreation"
self.play(graphing_stuff.animate.shift(DOWN*4))
self.play(axes.animate.shift(LEFT*3), RUN_TIME = 3)https://stackoverflow.com/questions/69167288
复制相似问题