Creating histograms on two variables
Just like a boxplot, a histogram can also be used for univariate analysis and bivariate analysis. For bivariate analysis, a histogram is useful for analyzing numerical-categorical variables. It is usually straightforward when our categorical variable has only two categories. However, it becomes complex when we have more than two categories. Typically, in bivariate analysis using histograms, we can overlay the histogram for each of the categories over each other and assign a specific color to the histogram representing each category. This helps us to easily identify distinct distributions of our continuous variable across categories in our categorical variable of interest. This approach is best only for categorical variables with at most three categories.
In this recipe, we will explore how to create histograms in seaborn
. The histplot
method in seaborn
can be used for this.
Getting ready
We will continue working with the Palmer Archipelago...