Wednesday, July 3, 2024
HomeLanguagesPythonMatplotlib.axis.Axis.update() function in Python

Matplotlib.axis.Axis.update() function in Python

Matplotlib is a library in Python and it is numerical ā€“ mathematical extension for NumPy library. It is an amazing visualization library in Python for 2D plots of arrays and used for working with the broader SciPy stack.

Matplotlib.axis.Axis.update() Function

The Axis.update() function in axis module of matplotlib library is used to update this artistā€™s properties from the dictionary props.Ā 
Ā 

Syntax: Axis.update(self, props)Ā 
Ā 

Parameters: This method accepts the following parameters.Ā 

  • props: This parameter is the dictionary of the properties.

Return value: This method does not return any value.Ā 

Below examples illustrate the matplotlib.axis.Axis.update() function in matplotlib.axis:
Ā 

Example 1:

Python3




# Implementation of matplotlib function
from matplotlib.axis import Axis
import matplotlib.pyplot as pltĀ Ā 
import numpy as npĀ Ā 
Ā Ā Ā Ā 
Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā 
np.random.seed(10**7)Ā Ā 
neveropen = np.random.randn(100)Ā Ā 
Ā Ā Ā Ā Ā Ā Ā 
fig, ax = plt.subplots()Ā Ā 
ax.acorr(neveropen, usevlines = True,Ā Ā 
Ā Ā Ā Ā Ā Ā Ā Ā Ā normed = True,Ā Ā 
Ā Ā Ā Ā Ā Ā Ā Ā Ā maxlags = 80, lw = 3)Ā Ā 
Ā Ā Ā Ā Ā Ā 
ax.grid(True)Ā Ā 
Ā Ā Ā Ā Ā Ā 
prop = {'xticks': np.array([-10., -5.,Ā 
Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā 0., 5., 10.]),Ā Ā 
Ā Ā Ā Ā Ā Ā Ā Ā 'yticks': np.array([-0.2,Ā  0.2,Ā Ā 
Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā 0.6, 1., 1.4]),Ā Ā 
Ā Ā Ā Ā Ā Ā Ā Ā 'ylabel': None, 'xlabel': None}Ā Ā 
Ā Ā Ā Ā Ā Ā 
Axis.update(ax, prop)
Ā Ā 
plt.title('matplotlib.axis.Axis.update() \
function Example', fontweight ="bold")Ā Ā 
Ā Ā Ā Ā 
plt.show()Ā 


Output:Ā 
Ā 

Example 2:

Python3




# Implementation of matplotlib function
from matplotlib.axis import Axis
import numpy as npĀ Ā Ā 
import matplotlib.pyplot as pltĀ Ā Ā 
Ā Ā Ā Ā Ā Ā 
Ā Ā Ā Ā Ā Ā 
xx = np.random.rand(16, 30)Ā Ā Ā 
Ā Ā Ā Ā Ā Ā Ā Ā Ā 
fig, ax = plt.subplots()Ā Ā Ā 
Ā Ā Ā Ā Ā Ā Ā Ā Ā 
m = ax.pcolor(xx)Ā Ā Ā 
m.set_zorder(-20)Ā Ā 
prop = {'autoscalex_on': False}Ā 
Ā Ā Ā Ā Ā Ā 
Axis.update(ax, prop)
Ā Ā 
plt.title('matplotlib.axis.Axis.update() \
function Example', fontweight ="bold")Ā Ā 
Ā Ā Ā Ā 
plt.show()Ā 


Output:Ā 
Ā 

Ā 

Ted Musemwa
As a software developer Iā€™m interested in the intersection of computational thinking and design thinking when solving human problems. As a professional I am guided by the principles of experiential learning; experience, reflect, conceptualise and experiment.
RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Most Popular

Recent Comments