import seaborn as sns
%matplotlib inline
tips = sns.load_dataset('tips')
tips.head(1)
sns.boxplot(x="day", y="total_bill", hue="smoker",data=tips, )
violinplot¶
A violin plot plays a similar role as a box and whisker plot. It shows the distribution of quantitative data across several levels of one (or more) categorical variables such that those distributions can be compared. Unlike a box plot, in which all of the plot components correspond to actual datapoints, the violin plot features a kernel density estimation of the underlying distribution.
sns.violinplot(x="day", y="total_bill", data=tips)
age=[11,12,13,14,15,11,12,13,14,15]
waight=[20,30,30,20,13,23,33,13,20,21]
sns.violinplot(age,waight)
sns.violinplot(x="day", y="total_bill", data=tips,hue="sex")
sns.violinplot(x="day", y="total_bill", data=tips,hue="sex",split=True)
stripplot¶
The stripplot will draw a scatterplot where one variable is categorical. A strip plot can be drawn on its own, but it is also a good complement to a box or violin plot in cases where you want to show all observations along with some representation of the underlying distribution.
The swarmplot is similar to stripplot(), but the points are adjusted (only along the categorical axis) so that they don’t overlap. This gives a better representation of the distribution of values, although it does not scale as well to large numbers of observations (both in terms of the ability to show all the points and in terms of the computation needed to arrange them).
sns.stripplot(x="day", y="total_bill", data=tips)
#sns.violinplot(x="day", y="total_bill", data=tips,hue="sex",split=True)
sns.stripplot(x="day", y="total_bill", data=tips,jitter=True)
sns.stripplot(x="day", y="total_bill", data=tips,hue='sex',jitter=True)
sns.stripplot(x="day", y="total_bill", data=tips,hue='sex',jitter=True,split=True)
sns.swarmplot(x="day", y="total_bill", data=tips)
sns.swarmplot(x="day", y="total_bill",hue='sex',data=tips, split=True)
sns.violinplot(x="day", y="total_bill", data=tips)
sns.swarmplot(x="day", y="total_bill", data=tips)
sns.violinplot(x="day", y="total_bill", data=tips)
sns.swarmplot(x="day", y="total_bill", data=tips,color="Black")
sns.violinplot(x="tip", y="day", data=tips)
sns.swarmplot(x="tip", y="day", data=tips,color='black',size=3)
factorplot¶
factorplot is the most general form of a categorical plot. It can take in a kind parameter to adjust the plot type:
sns.factorplot(x='sex',y='total_bill',data=tips,kind='bar')
sns.factorplot(x='sex',y='total_bill',data=tips,kind='violin')
No comments:
Post a Comment