Stripplot
It basically creates a scatter plot based on the category.
Syntax:
stripplot([x, y, hue, data, order, …])
Example:
Python3
sns.stripplot(x = 'day' , y = 'total_bill' , data = df, jitter = True , hue = 'smoker' , dodge = True ) |
Output:
Explanation/Analysis –
- One problem with strip plot is that you can’t really tell which points are stacked on top of each other and hence we use the jitter parameter to add some random noise.
- jitter parameter is used to add an amount of jitter (only along the categorical axis) which can be useful when you have many points and they overlap, so that it is easier to see the distribution.
- hue is used to provide an addition categorical separation
- setting split=True is used to draw separate strip plots based on the category specified by the hue parameter.
Seaborn | Categorical Plots
Plots are basically used for visualizing the relationship between variables. Those variables can be either be completely numerical or a category like a group, class or division. This article deals with categorical variables and how they can be visualized using the Seaborn library provided by Python.
Seaborn besides being a statistical plotting library also provides some default datasets. We will be using one such default dataset called ‘tips’. The ‘tips’ dataset contains information about people who probably had food at a restaurant and whether or not they left a tip for the waiters, their gender, whether they smoke and so on.
Let us have a look at the tips dataset.
Code
Python3
# import the seaborn library import seaborn as sns # import done to avoid warnings from warnings import filterwarnings # reading the dataset df = sns.load_dataset( 'tips' ) # first five entries if the dataset df.head() |
Now lets proceed onto the plots so that we can how we can visualize these categorical variables.