

- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
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
Matplotlib animation not working in IPython Notebook?
To animate a plot in matplotlib, we can take the following steps −
Set the figure size and adjust the padding between and around the subplots.
Create a random data of shape 10X10 dimension.
Create a figure and a set of subplots, using subplots() method.
Makes an animation by repeatedly calling a function *func*, using FuncAnimation() class.
To update the contour value in a function, we can define a method animate that can be used in FuncAnimation() class.
To display the figure, use show() method.
Example
import numpy as np import matplotlib.pyplot as plt import matplotlib.animation as animation plt.rcParams["figure.figsize"] = [7.50, 3.50] plt.rcParams["figure.autolayout"] = True data = np.random.randn(800).reshape(10, 10, 8) fig, ax = plt.subplots() def animate(i): ax.clear() ax.contourf(data[:, :, i]) ani = animation.FuncAnimation(fig, animate, 5, interval=50, blit=False) plt.show()
Output
- Related Questions & Answers
- Automatically run %matplotlib inline in IPython Notebook
- Save figure as file from iPython notebook using Matplotlib
- How to set the matplotlib figure default size in ipython notebook?
- Plot width settings in ipython notebook\n\n
- Best way to display Seaborn/Matplotlib plots with a dark iPython Notebook profile
- Displaying rotatable 3D plots in IPython or Jupyter Notebook
- How to hide <matplotlib.lines.Line2D> in IPython notebook?
- How do I show the same Matplotlib figure several times in a single IPython notebook?
- How to dynamically update a plot in a loop in Ipython notebook?
- Hide Matplotlib descriptions in Jupyter notebook
- Animation with contours in matplotlib
- Creating 3D animation using matplotlib
- Except not working in MySQL?
- Make 3D plot interactive in Jupyter Notebook (Python & Matplotlib)
- How do I get interactive plots again in Spyder/Ipython/matplotlib?
Advertisements