Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Seaborn: barplot the counting not mean value of a column

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)
like image 362
nononono Avatar asked Mar 28 '16 21:03

nononono


People also ask

How do you show count in Seaborn barplot?

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.

What is estimator in Seaborn barplot?

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 is the difference between Countplot and barplot?

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)


1 Answers

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)

enter image description here

like image 96
Stop harming Monica Avatar answered Oct 25 '22 19:10

Stop harming Monica