0

所以 manim 安装正确我可以转换我可以看到乳胶公式,除了我试图绘制图表

from manimlib.imports import *

class PlotFunctions(GraphScene):
    CONFIG = {
    "x_min" : -10,
    "x_max" : 10,
    "x_tick_frequency": 1,
    "y_min" : -15,
    "y_max" : 15,
    "y_tick_frequency": 1,
    "graph_origin" : ORIGIN ,
    "function_color" : RED ,
    "axes_color" : GREEN,
    "x_labeled_nums" :range(-10,10,5),
    "y_labeled_nums":range(-15,15,5),

    }
    def construct(self):
        self.setup_axes(animate=True)
        func_graph=self.get_graph(self.func_to_graph,self.function_color)
        func_graph2=self.get_graph(self.func_to_graph2)
        #vert_line = self.get_vertical_line_to_graph(TAU,func_graph,color=YELLOW)
        #graph_lab = self.get_graph_label(func_graph, label = "\\cos(x)")
        #graph_lab2=self.get_graph_label(func_graph2,label = "\\sin(x)", x_val=-10, direction=UP/2)
        #two_pi = TexMobject("x = 2 \\pi")
        #label_coord = self.input_to_graph_point(TAU,func_graph)
        #two_pi.next_to(label_coord,RIGHT+UP)

        self.play(ShowCreation(func_graph),ShowCreation(func_graph2))
        #self.play(ShowCreation(vert_line), ShowCreation(graph_lab), ShowCreation(graph_lab2),ShowCreation(two_pi))

    def func_to_graph(self,x):
        return x*x

    def func_to_graph2(self,x):
        a=x-1
        b=x-2
        c=x-3
        d=x-4
        e=a*b
        f=c*d
        g=e/f
        return g


在我使用 abcd 的最后一部分中,我只是试图定义 (x-1)(x-2)/(x-3)(x-4) 并且我尝试正常但我仍然得到错误的图表 这是错误的图表

这是正确的图表

感谢您提供任何帮助如果可能的话

4

1 回答 1

0

首先,您必须确定连续的域,即 (a, b)、[c, d) 等。一旦有了它们,您必须为每个域创建一个图,即:

    grap1 = self.get_graph(lambda x:f(x), x_min = 1.001*a, x_max = 0.999*b)
    grap2 = self.get_graph(lambda x:f(x), x_min = c, x_max = 0.999*d)
    # and so on

然后,您可以将它们全部分组到一个图表中

    graph = VMobject(graph1,graph2)
    self.play(LaggedStartMap(ShowCreation,graph))

是一个例子。是我关于图表的视频教程。

于 2019-12-01T01:59:30.337 回答