Member-only story

Python Animations With Matplotlib

Make the most of your simulations by knowing how to animate graphs.

Artturi Jalli
Better Programming

--

Animated sine wave

In Python, plotting graphs is straightforward — you can use powerful libraries like Matplotlib. But when you are running simulations, basic plots may not always be enough. You may want to show an animation that helps you understand how the state changes over time.

Luckily, it’s just as easy to create animations as it is to create plots with Matplotlib.

In this guide, you are going to learn:

  • How to create a basic Matplotlib plot.
  • How to create a basic animated plot using Matplotlib.
  • How to create a live-updating graph of a stock price.

Matplotlib

Matplotlib is a commonly used visualization library in Python. You can plot interactive graphs, histograms, bar charts, and so on.

How to Install Matplotlib

Installing Matplotlib is simple. Just open up your terminal and run:

pip install matplotlib

Numpy

Also, if you don’t have numpy, please install it so you can follow the examples in this guide:

pip install numpy

--

--

Responses (3)

Write a response