Matplotlib.pyplot.axvline() in Python Last Updated : 21 Apr, 2020 Comments Improve Suggest changes Like Article Like Report Matplotlib is a plotting library for creating static, animated, and interactive visualizations in Python. Matplotlib can be used in Python scripts, the Python and IPython shell, web application servers, and various graphical user interface toolkits like Tkinter, awxPython, etc. Note: For more information, refer to Python Matplotlib – An Overview 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-source. Note: For more information, refer to Pyplot in Matplotlib matplotlib.pyplot.axvline() This function add the vertical lines across the axes of the plot Syntax: matplotlib.pyplot.axvline(x=0, ymin=0, ymax=1, **kwargs) Parameters: x : x position in data coordinates to place the vertical line ymin :vertical line starting position on y axis, it will take values between 0 and 1, 0 being bottom of the axis, 1 being top of the axis ymax :vertical line ending position on y axis, it will take values between 0 and 1, 0 being bottom of the axis, 1 being top of the axis **kwargs :Other optional parameters to change the properties of the line, like changing color, linewidth etc Example-1: Python3 1== # Importing matplotlib.pyplot as plt import matplotlib.pyplot as plt # Initialising values of x and y x =[0, 5, 10, 15, 20] y =[1, 3, 5, 6, 9] # Plotting the graph plt.plot(x, y) # Drawing red vertical line at # x = 2.5 starting at half the #length of y axis(ymin = 0.5) and #continuing till the end(ymax = 1) # And setting the color of line to red plt.axvline(x = 2.5, ymin = 0.5, ymax = 1, color ='red') plt.show() Output : Example-2 : Python3 1== import matplotlib.pyplot as plt x =[0, 5, 10, 15, 20] y =[1, 3, 5, 6, 9] plt.plot(x, y) # Drawing vertical line from 25 % # of the y-axis length to 80 % # And also increasing the linewidth plt.axvline(x = 2.5, ymin = 0.25, ymax = 0.80, linewidth = 8, color ='green') plt.show() Output: Example-3 : Python3 1== import matplotlib.pyplot as plt x =[0, 5, 10, 15, 20] y =[1, 3, 5, 6, 9] plt.plot(x, y) # Drawing vertical line from 25 % # of the y-axis length to 75 % # And also changing the linestyle plt.axvline(x = 2.5, ymin = 0.25, ymax = 0.75, linewidth = 4, linestyle ="--", color ='red') plt.show() Output: Comment More infoAdvertise with us Next Article Matplotlib.pyplot.axvline() in Python S sathvik chiramana Follow Improve Article Tags : Python AI-ML-DS Python-matplotlib Practice Tags : python Similar Reads Python Tutorial | Learn Python Programming Language Python Tutorial â Python is one of the most popular programming languages. Itâs simple to use, packed with features and supported by a wide range of libraries and frameworks. Its clean syntax makes it beginner-friendly.Python is:A high-level language, used in web development, data science, automatio 10 min read Machine Learning Tutorial Machine learning is a branch of Artificial Intelligence that focuses on developing models and algorithms that let computers learn from data without being explicitly programmed for every task. In simple words, ML teaches the systems to think and understand like humans by learning from the data.Machin 5 min read Python Interview Questions and Answers Python is the most used language in top companies such as Intel, IBM, NASA, Pixar, Netflix, Facebook, JP Morgan Chase, Spotify and many more because of its simplicity and powerful libraries. To crack their Online Assessment and Interview Rounds as a Python developer, we need to master important Pyth 15+ min read Python OOPs Concepts Object Oriented Programming is a fundamental concept in Python, empowering developers to build modular, maintainable, and scalable applications. By understanding the core OOP principles (classes, objects, inheritance, encapsulation, polymorphism, and abstraction), programmers can leverage the full p 11 min read Python Projects - Beginner to Advanced Python is one of the most popular programming languages due to its simplicity, versatility, and supportive community. Whether youâre a beginner eager to learn the basics or an experienced programmer looking to challenge your skills, there are countless Python projects to help you grow.Hereâs a list 10 min read Linear Regression in Machine learning Linear regression is a type of supervised machine-learning algorithm that learns from the labelled datasets and maps the data points with most optimized linear functions which can be used for prediction on new datasets. It assumes that there is a linear relationship between the input and output, mea 15+ min read Python Exercise with Practice Questions and Solutions Python Exercise for Beginner: Practice makes perfect in everything, and this is especially true when learning Python. If you're a beginner, regularly practicing Python exercises will build your confidence and sharpen your skills. To help you improve, try these Python exercises with solutions to test 9 min read Support Vector Machine (SVM) Algorithm Support Vector Machine (SVM) is a supervised machine learning algorithm used for classification and regression tasks. It tries to find the best boundary known as hyperplane that separates different classes in the data. It is useful when you want to do binary classification like spam vs. not spam or 9 min read Python Programs Practice with Python program examples is always a good choice to scale up your logical understanding and programming skills and this article will provide you with the best sets of Python code examples.The below Python section contains a wide collection of Python programming examples. These Python co 11 min read Python Data Types Python Data types are the classification or categorization of data items. It represents the kind of value that tells what operations can be performed on a particular data. Since everything is an object in Python programming, Python data types are classes and variables are instances (objects) of thes 9 min read Like