Box Plot in Python using Matplotlib17 Mar 2025 | 3 min read What is Box Plot?A Box plot is a way to visualize the distribution of the data by using a box and some vertical lines. It is known as the whisker plot. The data can be distributed between five key ranges, which are as follows:
Here IQR represents the InterQuartile Range which starts from the first quartile (Q1) and ends at the third quartile (Q3). Box Plot visualization![]() In the box plot, those points which are out of range are called outliers. We can create the box plot of the data to determine the following:
The range of the data from minimum to maximum is called the whisker limit. In Python, we will use the matplotlib module's pyplot module, which has an inbuilt function named boxplot() which can create the box plot of any data set. Syntax:In the boxplot() function, we have a lot of attributes which can be used to create a more attractive and amazing box plot of the data set.
Example1:We will create the random data set of the numpy array and create the box plot. Output: ![]() Explanation: In the above code, first of all, we have imported the numpy and matplotlib libraries in the code. Then we created the random dataset and plotted the box plot using the boxplot() function. Example2:We can create multiple box plots simultaneously in the same file. Output: ![]() Explanation: In the above code, we have four data sets using random methods of numpy. Then we have created the list of the four data sets and use this inside boxplot() function. Example 3:We can use some attributes of the boxplot() function to customize the plot. Output: ![]() Explanation: In the above code, we have created the four datasets using random functions and set them in a list. Now we have set the different colors for each box plot using the list of colors and using the function set_facecolor(). We have set the line width of each box plot and also set the labels for each box plot. We have set attribute vert =0, which means all the plots will be in horizontal mode. Next TopicBox-Cox Transformation in Python |
Introduction Urban planning and environmental tracking benefit greatly from using geospatial data, which is information about locations on the surface of the Earth. The Folium module is one of Python's greatest geographic data manipulation and visualization tools. A Python module called Folium makes it easier to make...
4 min read
In this tutorial, we will learn about the Pafy module. Pafy is a Python module used to download YouTube content and retrieve metadata. We will see how we perform the various operations using the Pafy module. It provides an easy way to access YouTube content and...
4 min read
Introduction: The Python os module offers a platform-independent method of interacting with the underlying operating system. It provides a range of functions and constants for working with files, directories, processes, and environment variables, among other things. Expanduser(): The os.path module's expanduser() function in Python expands the tilde character at...
2 min read
Python's in-built ConfigParser library is part of the base module. The library provides a console parser for easy file configuration consisting of pairs of name-key values. The popular worldwide accepted convention supported by this library is the "INI" syntax, utilized on the Microsoft platform most commonly. The...
7 min read
While learning Python and its basics, we all must have heard that Python is one of the most popular programming languages, and the demand for Python in the market is increasing with every passing day. It is also not very hard to depict the reasons behind...
7 min read
In this tutorial, we will write a Python program to find the maximum number of 1s in the given 2D matrix. In the given matrix, each row is sorted we need to get the row that consists of a maximum number of 1s. Let's see the...
7 min read
In this tutorial, we will learn how Python manages the memory or how Python handles our date internally. We will dive deep into this topic to understand internal working of Python and how it handles the memory. This tutorial will give a deep understanding of Python memory...
12 min read
As Data Scientists, we may not stick to data format. PDFs, short for Portable Document Format files, are a good source of data. There are many organizations that release their data in PDFs only. As Artificial Intelligence is expanding, we require more data for prediction and...
3 min read
LastPass is a popular password management tool that allows users to securely store and manage their passwords. While there is no official Python module for LastPass, there are several third-party libraries and tools that can be used to interact with LastPass from Python. One such library is...
6 min read
In recent years, deep learning has altered the field of computer vision, enabling computers to perceive and figure out visual information at uncommon levels. Convolutional Neural Networks (CNNs) play had a crucial impact on this change, with a few groundbreaking designs leading the way. Two of...
6 min read
We request you to subscribe our newsletter for upcoming updates.
We provides tutorials and interview questions of all technology like java tutorial, android, java frameworks
G-13, 2nd Floor, Sec-3, Noida, UP, 201301, India