Visualization with Count Plots
Learn how to style and customize count plots according to the needs of the data.
We'll cover the following...
Overview
Count plots are used to count the number of instances each category has. We use it for categorical data to represent the number of instances of each unique category in the form of bars.
Plotting count plots
Let’s start by importing the required libraries and the tips dataset from seaborn library using the sns.load_dataset() function. Next, we can view the first five data records to get an overview of the data using the pandas head() function.
Let’s check the ratio of male and female customers in the tips dataset by passing x='sex' to the sns.countplot() function. The sns.countplot() function returns a bar container with all “artists” describing the bars in a count plot. Next, we call the bar_label() function to add labels to the bar. The function takes a container as input to add labels to the bars of the count plot.
In the example above, we saw that different ...