首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Manimlib轴没有属性“add_coordinates”

Manimlib轴没有属性“add_coordinates”
EN

Stack Overflow用户
提问于 2021-09-13 18:08:33
回答 1查看 409关注 0票数 0

我正在学习使用3blue1brown的Manim,它真的很酷。我正在网上学习一些教程,想了解一下绳子,但我遇到了一个问题

代码语言:javascript
复制
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”

我不知道出了什么问题。

我跟踪的Youtube视频

代码有变化吗?还是我不知道的事情?这些功能还存在吗?

EN

回答 1

Stack Overflow用户

发布于 2021-11-23 14:19:35

问题是,您复制了使用manim库的代码,并且正在导入manimlib (manim和manimlib互不兼容)。您可以安装那个版本的manim,而不使用manimlib,也可以将函数更改为manimlib中的函数。

代码语言:javascript
复制
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)
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/69167288

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档