Django Matplotlib动画嵌入到模板中

Django Matplotlib动画嵌入到模板中,django,animation,matplotlib,django-templates,django-views,Django,Animation,Matplotlib,Django Templates,Django Views,嗨,我正在django项目中使用matplot库。我可以在我的模板/网页中嵌入图形。我需要一些帮助,现在能够动画图形 图形存储为csv文件,其位置在我的模型中。我希望图形能够动态构建。现在我有了。但我想让它们成为动画。我该怎么做呢?顺便说一句,我必须使用matplotlib 我想拍个录像吧?我见过人们嵌入视频,但我希望使用matplotlib的实际动画功能,例如: 以下是我在视图中渲染图形的方式: def render_graph(request, graph_id=None): gr

嗨,我正在django项目中使用matplot库。我可以在我的模板/网页中嵌入图形。我需要一些帮助,现在能够动画图形

图形存储为csv文件,其位置在我的模型中。我希望图形能够动态构建。现在我有了。但我想让它们成为动画。我该怎么做呢?顺便说一句,我必须使用matplotlib

我想拍个录像吧?我见过人们嵌入视频,但我希望使用matplotlib的实际动画功能,例如:

以下是我在视图中渲染图形的方式:

def render_graph(request, graph_id=None):
    graph = get_object_or_404(models.Graph, pk=graph_id) #grabs actual graph
    data = np.genfromtxt(graph.data, delimiter=',', names=['x','y']) #extract data from cvs after x and y

    fig = Figure()
    ax = fig.add_subplot(111)

    ax.plot(data['x'], data['y'], label=graph.name)
    canvas=FigureCanvas(fig)

    response = HttpResponse(content_type='image/png')

    canvas.print_png(response)
    return(response)

你考虑过使用d3(d3js.org)吗?可能会得到更好的结果。

必须使用matplotlib。