Analyzing two variables using a bar chart
The bar chart can be used for both univariate and bivariate analysis. For bivariate analysis, the x axis typically represents the categories in our dataset, while the y axis represents a numerical variable. This means the bar chart is usually used for categorical-numerical analysis. The numerical variable is typically aggregated using functions such as the sum, median, mean, and so on. A bar chart provides quick insights, especially when we need to quickly compare categories within our dataset.
In this recipe, we will explore how to create bar charts for bivariate analysis in seaborn
. seaborn
has a barplot
method that is used for this. seaborn
also has a countplot
method that plots a bar chart; however, the countplot
method only plots the count of each category. Therefore, it is used for univariate analysis. The barplot
method, on the other hand, plots a numerical variable against each category.
Getting ready
We will continue working...