Skip to content
Related Articles

Related Articles

matplotlib.pyplot.pause() in Python

View Discussion
Improve Article
Save Article
  • Last Updated : 22 Apr, 2020
View Discussion
Improve Article
Save Article

Matplotlib is a library in Python and it is numerical – mathematical extension for NumPy library. Pyplot is a state-based interface to a Matplotlib module which provides a MATLAB-like interface.

matplotlib.pyplot.pause() Function:

The pause() function in pyplot module of matplotlib library is used to pause for interval seconds.

Syntax:

matplotlib.pyplot.pause(interval)

Parameters: This method does not accepts any parameters.

Return value: This method does not returns any value.

Below examples illustrate the matplotlib.pyplot.pause() function in matplotlib.pyplot:

Example #1:




# Implementation of matplotlib function
import numpy as np
import matplotlib.pyplot as plt
   
np.random.seed(19)
data = np.random.random((5, 10, 10))
  
   
for i in range(len(data)):
    plt.cla()
    plt.title('matplotlib.pyplot.pause() function Example\n\n Window {}'.format(i), fontweight ="bold")
    plt.imshow(data[i])
    plt.pause(0.1)

Output:

Example #2:




# Implementation of matplotlib function
from mpl_toolkits.mplot3d import axes3d
import matplotlib.pyplot as plt
   
fig = plt.figure()
ax = fig.add_subplot(111, projection ='3d')
   
X, Y, Z = axes3d.get_test_data(0.1)
ax.plot_wireframe(X, Y, Z, rstride = 5, cstride = 5)
   
for angle in range(0, 360):
    ax.view_init(30, angle)
    plt.draw()
    plt.pause(.001)
    ax.set_title('matplotlib.pyplot.pause() function Example', fontweight ="bold")

Output:


My Personal Notes arrow_drop_up
Recommended Articles
Page :

Start Your Coding Journey Now!