- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Avoid the points getting overlapped without using jitter parameter in categorical scatter plot in Python Seaborn?
We will be using Seaborn. Seaborn is a library that helps in visualizing data. It comes with customized themes and a high-level interface. This interface helps in customizing and controlling the kind of data and how it behaves when certain filters are applied to it.
The ‘stripplot’ function is used when atleast one of the variables is categorical. The data is represented in a sorted manner along one of the axes. But the disadvantage is that certain points get overlapped. This where the ‘jitter’ parameter has to be used to avoid the overlapping between variables.
It adds some random noise to the dataset, and adjusts the positions of the values along the categorical axis. But, instead of using the ‘jitter’ parameter, we can use the ‘swarmplot’ to get categorical scatter plot.
Syntax of swarmplot function
seaborn.swarmplot(x, y,data,…)
It has been demonstrated below −
Example
import pandas as pd import seaborn as sb from matplotlib import pyplot as plt my_df = sb.load_dataset('iris') sb.swarmplot(x = "species", y = "petal_length", data = my_df) plt.show()
Output
Explanation
- The required packages are imported.
- The input data is ‘iris_data’ which is loaded from the scikit learn library.
- This data is stored in a dataframe.
- The ‘load_dataset’ function is used to load the iris data.
- This data is visualized using the ‘swarmplot’ function.
- Here, the dataframe is supplied as parameter.
- Also, the x and y values are specified.
- This data is displayed on the console.