Dynamic build using Django and matplotlib

These days I am trying to create a web page where you can watch a dynamic graphic demonstration. I am using Django to create a web page, and recently found out that matplotlib.animation can do this kind of work. I wonder if this API, matplitlib.animation, can be used when creating a web page using Django. (I tried to do this using HttpResponse, but only for failure.) If there is any other way to do this, please let me know. Thanks in advance.

+4
source share
1 answer

You need to write the animation to disk, and then run it through some static interface. Here is an idea on how to do this:

Make your web server item / animation in / var / www / animations

Save the animation in this folder (you can save mp4 and use HTML5, but if you want to save GIF this SO contains information about what you need. Use the model to store the initialization parameters and hash from them (which would make a decent file name).

Change it in your templates with the usual img tag (or video tag if you are using mp4).

0
source

All Articles