Visualization with Cat Plots
Explore how to create categorical plots in Seaborn using the catplot function. Understand how to customize plots like bar, violin, box, and swarm, and use FacetGrid features for multiple facets and enhanced visualization control.
We'll cover the following...
Overview
The cat plot stands for the categorical plot, which represents the relationship between variables. We can access all the categorical plots, such as bar, box, violin, swarm, and so on. It’s built on top of seaborn’s FacetGrid, which means we can have multiple plots within the same plot. The default cat plot is a strip plot.
Plotting cat plots
We’ve already imported the required libraries and saved the titanic dataset in the titanic_df DataFrame (after removing the null values). Let’s get started with the visualizations. We call the sns.catplot() function and pass x='age':
By default, the cat plot shows a strip plot. However, we can switch the plot by specifying it in the kind parameter in the sns.catplot() function. For example, let’s draw a violin plot through a cat plot by specifying kind='violin'. We can access all the categorical plots by specifying them in the ...