Barplot
A barplot is basically used to aggregate the categorical data according to some methods and by default it’s the mean. It can also be understood as a visualization of the group by action. To use this plot we choose a categorical column for the x-axis and a numerical column for the y-axis, and we see that it creates a plot taking a mean per categorical column.
Syntax:
barplot([x, y, hue, data, order, hue_order, …])
Python3
# import the seaborn library import seaborn as sns # reading the dataset df = sns.load_dataset( 'tips' ) # change the estimator from mean to # standard deviation sns.barplot(x = 'sex' , y = 'total_bill' , data = df, palette = 'plasma' ) |
Output:
Explanation:
Looking at the plot we can say that the average total_bill for the male is more than compared to the female.
- Palette is used to set the color of the plot
- The estimator is used as a statistical function for estimation within each categorical bin.
Plotting graph using Seaborn | Python
This article will introduce you to graphing in Python with Seaborn, which is the most popular statistical visualization library in Python.
Installation: The easiest way to install seaborn is to use pip. Type following command in terminal:
pip install seaborn
OR, you can download it from here and install it manually.
Plotting categorical scatter plots with Seaborn