How To Manually Order Boxplot in Seaborn?
Seaborn is an amazing visualization library for statistical graphics plotting in Python. It provides beautiful default styles and color palettes to make statistical plots more attractive. It is built on the top of matplotlib library and also closely integrated into the data structures from pandas.
Seaborn aims to make visualization of the central part of exploring and understanding data. It provides dataset-oriented APIs, so that we can switch between different visual representations for the same variables for a better understanding of the dataset.
Box Plot is the visual representation of the depicting groups of numerical data through their quartiles. Boxplot is also used for detecting the outlier in the data set. It captures the summary of the data efficiently with a simple box and whiskers and allows us to compare easily across groups. Boxplot summarizes sample data using 25th, 50th, and 75th percentiles. These percentiles are also known as the lower quartile, median and upper quartile.
Attention geek! Strengthen your foundations with the Python Programming Foundation Course and learn the basics.
To begin with, your interview preparations Enhance your Data Structures concepts with the Python DS Course. And to begin with your Machine Learning Journey, join the Machine Learning - Basic Level Course
In this article, we will discuss how to order a boxplot manually.
The dataset used in the below example is https://www.kaggle.com/ranjeetjain3/seaborn-tips-dataset
- Import libraries
- Load dataset
- Plot the boxplot.
- Plotting the boxplot using seaborn. See the difference in the order of the above figure and after setting the order as per our needs. Palette will change the color of the graph (you can try Set1 and Set3 as well)
- Both graphs together:
Below is the complete program based on the above approach:
Now, Plotting the boxplot using different features. Observe the order on the x-axis in the figure given below:
Here we have manually ordered the boxplot.