 
  Data Structure Data Structure
 Networking Networking
 RDBMS RDBMS
 Operating System Operating System
 Java Java
 MS Excel MS Excel
 iOS iOS
 HTML HTML
 CSS CSS
 Android Android
 Python Python
 C Programming C Programming
 C++ C++
 C# C#
 MongoDB MongoDB
 MySQL MySQL
 Javascript Javascript
 PHP PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How to plot an animated image matrix in matplotlib?
To plot an animated image matrix in matplotlib, we can take the following steps
Steps
- Set the figure size and adjust the padding between and around the subplots. 
- Create a figure and a set of subplots. 
- Make an animation by repeatedly calling a function *update*. 
- Inside the update method, create a 6×6 dimension of matrix and display the data as an image, i.e., on a 2D regular raster. 
- Turn off the axes using set_axis_off(). 
- To display the figure, use Show() method. 
Example
from matplotlib.animation import FuncAnimation import matplotlib.pyplot as plt import numpy as np plt.rcParams["figure.figsize"] = [7.00, 3.50] plt.rcParams["figure.autolayout"] = True fig, ax = plt.subplots() def update(i): im_normed = np.random.rand(6, 6) ax.imshow(im_normed) ax.set_axis_off() anim = FuncAnimation(fig, update, frames=20, interval=50) plt.show()
Output
It will produce the following output −

Advertisements
 