"Coding Druid" series is my horizontal programming practice notes, each part around a topic like mathematical, physics, electronic, graphics, sound, etc., implemented in several programming languages.
Chapter: Trigonometric Function
This time I use Python to implement it.
For the quick goal, directly Google "python data visualization lib" these keywords, get the lib, sort by the number of stars in github, found the old and strong Matplotlib. So, it was so pleasant to decide.
Consider the follow-up exercises, I select the whole-family-bucket installation method provided by Anaconda. It includes a bunch of libraries related to scientific data analysis including Matplotlib.
Due to the recent unfixed working computer and location, I've deployed a remote development environment (VSCode Remote rocks!). The code is deploying and running on the Azure server. I just use a old notebook to edit the code and view the effect.
So I choose the Linux version for the server environment.
Note, the Python 3.x version on the left is preferred here, because Matplotlib 3.0 and above only supports Python 3.
Matplotlib 3.0 is Python 3 only.
For Python 2 support, Matplotlib 2.2.x will be continued as a LTS release and updated with bugfixes until January 1, 2020.
Then you can start coding after Matplotlib installing.
(In fact, after writing a few lines, I found that remotely developing Python, it is still not convenient to view the result graphics in real time. So I also installed Jupyter Notebook and coding directly in the browser, WYSIWYG.)
In addition, ffmpeg is installed too, to save the animation obtained by Matplotlib to mp4.
Also used Anaconda to install ffmpeg.
conda install -c conda-forge ffmpeg
With Matplotlib, the Sine function animation part, in fact, there is not a few code. Most is actually the coordinate configuration, and draw some auxiliary lines and so on.
Basically coding by according to the tutorial and some reference articles. The characteristics of this library, most of the ideas focus on the algorithmic logic of the mathematical formula itself.
A nice reference article:
Animations with Matplotlib
Talk is cheap. Show me the code!
This demo of the "Coding Druid" series is open source here: