Articles → MATPLOTLIB → Add An Axes Dynamically In Matplotlib Using Add_Axes Function

Add An Axes Dynamically In Matplotlib Using Add_Axes Function






Steps




  1. Create a figure object (which is a blank canvas).
  2. Call an add_axes function to add axis.
  3. Plot the graph.

Example


import matplotlib.pyplot as plt
import array 

arr1 = array.array('i', [1, 2, 3])
arr2 = array.array('i', [4, 5, 6])

# Create a figure object
fig = plt.figure()
# add axis
axes = fig.add_axes([.1,.1,.8,.8])
# Plot graph
axes.plot(arr1,arr2)
# Show graph
plt.show()





Output


Picture showing the output of  adding an axes using 'add_axes' function



Posted By  -  Karan Gupta
 
Posted On  -  Tuesday, June 18, 2019

Query/Feedback


Your Email Id  
 
Subject 
 
Query/FeedbackCharacters remaining 250