Data Visualisation Using Seaborn

Lets create a barplot of “total_bill” with “sex” and let’s see who pays more Males or Females.sns.barplot(x = , y =, data=)# Barplotsns.barplot(x ="sex" , y ="total_bill" , data=tips)# Inference – Total Bill Amount for males is more than Females.# Lets Plot Smoker Vs Total Bill :: The purpose is to find out if # Smokers pay more bill than Non Smokerssns.barplot(x = "smoker", y = "total_bill", data =tips)# Inference – More Bill for Smokers# Lets Find If There is more Bill In Weekend or Weekdayssns.barplot(x = "day", y = "total_bill", data =tips)# People tend to visit more on weekendsBoxplotA Box Plot is a visual representation of five point summary statistics of a given data set..A five number summary includes:MinimumFirst QuartileMedian (Second Quartile)Third QuartileMaximumAlso, a point worth noticing is that a boxplot is created for Categorical — Continuous Variables which means that if the x -axis is categorical and y axis is continuous then a boxplot or a violin plot should be created.Lets create a boxplot of “day” & “total_bill” from the tips dataset..Here is the syntax for the same.sns.boxplot(x = , y =, data=)# Boxplotsns.boxplot(x = "day", y = "total_bill", data=tips)# Add hue to split the barplot..Making it more fanciersns.boxplot(x = "day", y = "total_bill", data=tips, hue = "smoker")# On Friday people have more bill if they are a Non smoker vs smokerhue = “smoker”: — It has created a boxplot for smokers & non smokers..For e.g..in the case of Friday, its clearly seen that food bill is more in the case of non smoker when compared to smokers on that day.# Violin Plotssns.violinplot(x = "day", y = "total_bill", data = tips)The violin plots are similar to the boxplots..The same can be seen in the image below.LM Plotsns.lmplot is a plot that fits the regression line to the dataset showing as scatterplots..It follows the ordinary least square method and the line represents the best fit line..One must read a little bit about linear regression in order to understand this better.Here is the code of the lmplot# LM PLotsns.lmplot(x = "total_bill", y = "tip", data = tips, hue="day")This shows the linear regression fit of total_bill variable for the different days as shown in the plot legend..This is obtained using hue = “day” in sns.lmplot.Congratulations!!.You have finished the Seaborn Tutorial for Beginners..Hope this article would have provided a basic understanding around Seaborn and would have helped you in creating all these plots.Please share your views and suggestions to make it better.. More details

Leave a Reply