I am the beginner with seaborn plot. as the sample, seaborn provides a bar graph with the average "days". However, is it possible to provide a bar graph with total(sum), counting,..of the days values?
import seaborn as sns
sns.set_style("whitegrid")
tips = sns.load_dataset("tips")
ax = sns.barplot(x = "day",y = "total_bill",data=tips)
countplot() method is used to Show the counts of observations in each categorical bin using bars. Parameters : This method is accepting the following parameters that are described below: x, y: This parameter take names of variables in data or vector data, optional, Inputs for plotting long-form data.
The estimator argument of the barplot() method in Seaborn can alter how the data is aggregated. By default, each bin of a barplot displays the mean value of a variable. Using the estimator argument this behaviour would be different. The estimator argument can receive a function such as np. sum , len , np.
What's the difference? Here's the simple difference: countplot plots the count of the number of records by category. barplot plots a value or metric for each category (by default, barplot plots the mean of a variable, by category)
From the docstring:
Parameters: ----------- [...] estimator : callable that maps vector -> scalar, optional Statistical function to estimate within each categorical bin.
So
ax = sns.barplot(x="day", y="total_bill", data=tips, estimator=sum)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With