In [1]:
import seaborn as sns
%matplotlib inline
tips = sns.load_dataset('tips')
tips.head(1)
Out[1]:
countplot¶
This is essentially the same as barplot except the estimator is explicitly counting the number of occurrences. Which is why we only pass the x value:
In [5]:
sns.countplot(x='sex',data=tips)
Out[5]:
In [7]:
sns.countplot(x='size',data=tips)
Out[7]:
In [8]:
sns.countplot(x='total_bill',data=tips)
Out[8]:
boxplot and violinplot¶
boxplots and violinplots are used to shown the distribution of categorical data. A box plot (or box-and-whisker plot) shows the distribution of quantitative data in a way that facilitates comparisons between variables or across levels of a categorical variable. The box shows the quartiles of the dataset while the whiskers extend to show the rest of the distribution, except for points that are determined to be “outliers” using a method that is a function of the inter-quartile range.
In [9]:
sns.boxplot(x="day", y="total_bill", data=tips,palette='rainbow')
Out[9]:
In [10]:
# Can do entire dataframe with orient='h'
sns.boxplot(data=tips,palette='rainbow',orient='h')
Out[10]:
In [12]:
sns.boxplot(x="day", y="total_bill", hue="smoker",data=tips, )
Out[12]:
No comments:
Post a Comment