Matplotlib.axes.Axes.axvline() in Python Last Updated : 21 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. 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.axvline() Function The Axes.axvline() function in axes module of matplotlib library is used to add a vertical line across the axis. Syntax: Axes.axvline(self, x=0, ymin=0, ymax=1, **kwargs) Parameters: This method accept the following parameters that are described below: x: This parameter is the x position in data coordinates of the vertical line with default value of 0. ymin: This parameter should be between 0 and 1, 0 being the bottom of the plot, 1 the top of the plot.Its default value of 0. ymax: This parameter should be between 0 and 1, 0 being the bottom of the plot, 1 the top of the plot. Its default value of 1. Returns: This returns the following: lines:This returns the list of Line2D objects representing the plotted data. Below examples illustrate the matplotlib.axes.Axes.axhline() function in matplotlib.axes: Example 1: Python3 # Implementation of matplotlib function import matplotlib.pyplot as plt import numpy as np import matplotlib.collections as collections t = np.arange(0.0, 5, 0.01) s1 = np.sin(4 * np.pi * t) fig, ax = plt.subplots() ax.plot(t, s1, color ='black', alpha = 0.75, lw = 1) ax.axvline(3, color ='green', lw = 2, alpha = 0.75) ax.set_title('matplotlib.axes.Axes.axvline() Example') plt.show() Output: Example 2: Python3 # Implementation of matplotlib function import matplotlib.pyplot as plt import numpy as np t = np.linspace(-10, 10, 100) sig = 1 / t**2 fig, ax = plt.subplots() plt.axvline(color ="green", alpha = 0.8, lw = 1.5) plt.plot(t, sig, linewidth = 1.5, color ="black", alpha = 0.6, label = r"$\sigma(t) = \frac{1}{x ^ 2}$") plt.xlim(-10, 10) plt.xlabel("t") plt.legend(fontsize = 14) ax.set_title('matplotlib.axes.Axes.axvline() Example') plt.show() Output: Comment More infoAdvertise with us Next Article Matplotlib.axes.Axes.axvline() in Python S SHUBHAMSINGH10 Follow Improve Article Tags : Python Python-matplotlib Practice Tags : python Similar Reads Matplotlib.axes.Axes.hlines() in Python 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. 2 min read Matplotlib.axes.Axes.axis() in Python The Axes.axis() function in Matplotlib is used to get or set the properties of the x-axis and y-axis limits on a given Axes object. It provides an easy way to control the view limits, aspect ratio, and visibility of the axes in a plot. It's key feature include:Get the current axis limits as [xmin, x 2 min read Matplotlib.axes.Axes.axvspan() in Python 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. 2 min read matplotlib.axes.Axes.axhspan() in Python 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. 2 min read Matplotlib.axes.Axes.inset_axes() in Python 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. 2 min read Like