Matplotlib.pyplot.axhspan() in Python Last Updated : 27 Apr, 2020 Comments Improve Suggest changes Like Article Like Report 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.axhspan() Function The axhspan() function in pyplot module of matplotlib library is used to add a horizontal span (rectangle) across the axis. Syntax: matplotlib.pyplot.axhspan(ymin, ymax, xmin=0, xmax=1, **kwargs) Parameters: This method accept the following parameters that are described below: ymin: This parameter is the lower limit of the horizontal span in data units. ymax: This parameter is the upper limit of the horizontal span in data units. xmin: This parameter is the lower limit of the vertical span in data units. xmax: This parameter is the upper limit of the vertical span in data units. Returns: This returns the Polygon. Below examples illustrate the matplotlib.pyplot.axhspan() function in matplotlib.pyplot: Example 1: Python3 1== import matplotlib.pyplot as plt # xmin = 0 and xmax = 1 is the # default value plt.axhspan(0.25, 0.75, facecolor ='r', alpha = 0.7) Output: Example 2: Python3 #Implementation of matplotlib function import numpy as np import matplotlib.pyplot as plt t = np.arange(-2, 3, .01) s = np.sin(np.pi * t) plt.plot(t, s, color ='black') plt.axhline(y = 1, color ='black') plt.axvline(x = 1, color ='black') plt.axvline(x = 0.5, ymin = 0.75, linewidth = 8, color ='green') plt.axhline(y =.5, xmin = 0.25, xmax = 0.75, color ='black') plt.axhspan(0.25, 0.75, facecolor ='0.5', alpha = 0.5) plt.axvspan(2.25, 2.55, facecolor ='green', alpha = 0.5) plt.title('matplotlib.pyplot.axhspan() Example\n', fontsize=14, fontweight='bold') plt.show() Output: Comment More infoAdvertise with us Next Article Matplotlib.pyplot.axhspan() in Python D dhruv_tewari Follow Improve Article Tags : Python Python-matplotlib Matplotlib Pyplot-class Practice Tags : python Similar Reads Matplotlib.pyplot.axvspan() in Python Matplotlib is a plotting library for creating static, animated, and interactive visualizations in Python.\ Pyplot is a Matplotlib module which provides a MATLAB-like interface. Matplotlib is designed to be as usable as MATLAB, with the ability to use Python and the advantage of being free and open-s 2 min read Matplotlib.pyplot.axes() in Python axes() method in Matplotlib is used to create a new Axes instance (i.e., a plot area) within a figure. This allows you to specify the location and size of the plot within the figure, providing more control over subplot layout compared to plt.subplot(). It's key features include:Creates a new Axes at 3 min read Matplotlib.pyplot.axis() in Python axis() function in Matplotlib is used to get or set properties of the x- and y-axis in a plot. It provides control over axis limits, aspect ratio and visibility, allowing customization of the plotâs coordinate system and view. It's key feature includes:Gets or sets the axis limits [xmin, xmax, ymin, 3 min read matplotlib.pyplot.axhline() in Python 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.axhline() Function The axhline() function in pyplot module of matplotlib library is use 2 min read Matplotlib.pyplot.hsv() in Python 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.hsv() Function The hsv() function in pyplot module of matplotlib library is used to set 2 min read Like