Open In App

Matplotlib.figure.Figure.draw() in Python

Improve
Improve
Like Article
Like
Save
Share
Report

Matplotlib is a library in Python and it is numerical – mathematical extension for NumPy library. The figure module provides the top-level Artist, the Figure, which contains all the plot elements. This module is used to control the default spacing of the subplots and top level container for all plot elements.

matplotlib.figure.Figure.draw() function

The draw() method figure module of matplotlib library is used to render the figure using matplotlib.backend_bases.RendererBase instance renderer.

Syntax: draw(self, renderer)

Parameters: This accept the following parameters that are described below:

  • renderer: This parameter is the matplotlib.backend_bases.RendererBase instance renderer.

Returns: This method does not return any value.

Below examples illustrate the matplotlib.figure.Figure.draw() function in matplotlib.figure:

Example 1:




# Implementation of matplotlib function 
from mpl_toolkits.mplot3d import axes3d 
import matplotlib.pyplot as plt 
     
fig, ax = plt.subplots() 
     
def tellme(s): 
    ax.set_title(s, fontsize = 16
    fig.canvas.draw()
    renderer = fig.canvas.renderer
    fig.draw(renderer)
   
tellme('matplotlib.figure.Figure.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, 90): 
    ax.view_init(30, angle)
    fig.canvas.draw()
    renderer = fig.canvas.renderer
    fig.draw(renderer) 
    plt.pause(.001)
  
    fig.suptitle('matplotlib.figure.Figure.draw() \
    function Example')


Output:



Last Updated : 30 Apr, 2020
Like Article
Save Article
Previous
Next
Share your thoughts in the comments
Similar Reads