Open In App

Matplotlib.pyplot.draw() in Python

Last Updated : 21 Apr, 2020
Comments
Improve
Suggest changes
Like Article
Like
Report
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.draw() Function

The draw() function in pyplot module of matplotlib library is used to redraw the current figure.
Syntax: matplotlib.pyplot.draw()
Below examples illustrate the matplotlib.pyplot.draw() function in matplotlib.pyplot: Example #1:Python3 1==
# Implementation of matplotlib function
import numpy as np
import matplotlib.pyplot as plt


def tellme(s):
    plt.title(s, fontsize = 16)
    plt.draw()
plt.clf()
plt.setp(plt.gca(), autoscale_on = False)

tellme('matplotlib.pyplot.draw() function Example')
plt.show()
Output: Example #2:Python3 1==
# 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.draw()\
    function Example', fontweight ="bold")
Output:

Next Article
Practice Tags :

Similar Reads