Skip to content
Related Articles

Related Articles

Improve Article

Matplotlib.pyplot.draw() in Python

  • Last Updated : 21 Apr, 2020

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:






# 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:




# 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:

 Attention geek! Strengthen your foundations with the Python Programming Foundation Course and learn the basics.  

To begin with, your interview preparations Enhance your Data Structures concepts with the Python DS Course. And to begin with your Machine Learning Journey, join the Machine Learning – Basic Level Course




My Personal Notes arrow_drop_up
Recommended Articles
Page :