Matplotlib.axes.Axes.get_navigate() in Python
Last Updated :
19 Apr, 2020
Matplotlib is a library in Python and it is numerical – mathematical extension for NumPy library. The Axes Class contains most of the figure elements: Axis, Tick, Line2D, Text, Polygon, etc., and sets the coordinate system. And the instances of Axes supports callbacks through a callbacks attribute.
matplotlib.axes.Axes.set_navigate() Function
The Axes.get_navigate() Function in axes module of matplotlib library is used to get whether the axes responds to navigation commands.
Syntax: Axes.get_navigate(self)
Parameters: This method does not accept any parameters.
Return value: This method returns navigation points.
Below examples illustrate the matplotlib.axes.Axes.get_navigate() function in matplotlib.axes:
Example 1:
import matplotlib.pyplot as plt
from mpl_toolkits.axisartist.axislines import SubplotZero
import numpy as np
fig, ax = plt.subplots()
xx = np.arange( 0 , 2 * np.pi, 0.01 )
ax.plot(xx, np.sin(xx))
ax.set_navigate( False )
w = ax.get_navigate()
ax.text( 2 , 0 , "Value Return : " + str (w),
fontweight = "bold" )
fig.suptitle('matplotlib.axes.Axes.get_navigate() function\
Example\n\n', fontweight = "bold" )
plt.show()
|
Output:
Example 2:
import matplotlib.pyplot as plt
import numpy as np
fig, (ax, ax1) = plt.subplots( 1 , 2 )
ax.plot([ 1 , 2 , 3 ])
ax.grid()
ax1.plot([ 1 , 2 , 3 ])
ax1.grid()
ax.set_navigate( False )
ax.set_title( "Axes 1" )
ax1.set_title( "Axes 2" )
w = ax.get_navigate()
ax.text( 0.25 , 2 , "Value Return : " + str (w),
fontweight = "bold" )
w = ax1.get_navigate()
ax1.text( 0.25 , 2 , "Value Return : " + str (w),
fontweight = "bold" )
fig.suptitle('matplotlib.axes.Axes.get_navigate()\
function Example\n\n', fontweight = "bold" )
plt.show()
|
Output:
Share your thoughts in the comments
Please Login to comment...