Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Count and Hist plot
- plt.figure(figsize = (12,8))
- sns.set(font_scale = 2, palette = "viridis")
- sns.countplot(data = titanic, x = "sex", hue = "pclass")
- plt.show()
- sns.histplot(data = penguins, x = "body_mass_g", kde = True)
- sns.histplot(data = penguins, x = "body_mass_g", kde = True, hue = "species")
- #############################################################################################################################
- # Categorical plots
- plt.figure(figsize=(12,8))
- sns.set(font_scale=1.5)
- sns.stripplot(data = titanic, x = "sex", y = "age", jitter = True, hue = "pclass", dodge = True)
- plt.show()
- plt.figure(figsize=(12,8))
- sns.set(font_scale=1.5)
- sns.swarmplot(data = titanic, x = "sex", y = "age", hue = "pclass", dodge = True)
- plt.show() # the plot is the same as previous plot, but we can see the distribution
- plt.figure(figsize=(12,8))
- sns.set(font_scale=1.5)
- sns.violinplot(data = titanic, x = "sex", y = "age", hue = "pclass", dodge = True)
- sns.swarmplot(data = titanic, x = "sex", y = "age", hue = "pclass", dodge = True, color = "black")
- plt.show() # we can see the distribution
- plt.figure(figsize=(12,8))
- sns.set(font_scale=1.5)
- sns.violinplot(data = titanic, x = "pclass", y = "age", hue = "sex", dodge = True, split = True )
- plt.show()
- plt.figure(figsize=(12,8))
- sns.set(font_scale=1.5)
- sns.barplot(data = titanic, x = "pclass", y = "age", hue = "sex", dodge = True)
- plt.show() # with confidence intervals
- plt.figure(figsize=(12,8))
- sns.set(font_scale=1.5)
- sns.pointplot(data = titanic, x = "pclass", y = "age", hue = "sex", dodge = True)
- plt.show() # only CONFIDENCE INTERVALS for each groups
- ##########################################################################################################################
- # Joint / Regression plot
- sns.set(font_scale=1.5)
- sns.regplot(data = df, x = 'total_spend', y = 'sales')
- sns.jointplot(data = titanic, x = "age", y = "fare", height = 8, kind = "kde")
- plt.show()
- sns.set(font_scale=1.5)
- sns.jointplot(data = titanic, x = "age", y = "fare", height = 8, kind = "scatter")
- plt.show()
- sns.set(font_scale=1.5)
- sns.jointplot(data = titanic, x = "age", y = "fare", height = 8, kind = "hex")
- plt.show()
- sns.set(font_scale=1.5)
- sns.jointplot(data = titanic, x = "age", y = "fare", height = 8, kind = "reg")
- plt.show()
- sns.set_style('whitegrid')
- sns.lmplot(x ='total_bill', y ='tip', data = dataset,
- hue ='sex', markers = ['o', 'v']) # LINEAR REGRESSION PLOT
- sns.set_style('whitegrid')
- sns.lmplot(x ='total_bill', y ='tip', data = dataset, hue ='sex',
- markers =['o', 'v'], scatter_kws ={'s':100},
- palette ='plasma')
- sns.set(font_scale=1.5)
- sns.lmplot(data = titanic, x = "age", y = "fare", aspect= 1, height=8, col = "sex")
- plt.show() # we are creating two subplots and actually two columns for male and female
- sns.set(font_scale=1.5)
- sns.lmplot(data = titanic, x = "age", y = "fare", aspect= 1, height=8, row = "sex")
- plt.show() # we are creating two subplots and actually two rows for male and female
- sns.lmplot(x ='total_bill', y ='tip', data = dataset,
- col ='sex', row ='time', hue ='smoker')
- sns.lmplot(x ='total_bill', y ='tip', data = dataset, col ='sex',
- row ='time', hue ='smoker', aspect = 0.6,
- size = 4, palette ='coolwarm')
- sns.set(font_scale=1.5)
- sns.lmplot(data = titanic, x = "age", y = "survived", aspect= 1, height=8, col = "sex", logistic= True)
- plt.show() # plot for LOGISTIC REGRESSION
- ###########################################################################################################################
- # Heatmaps and Matrixplots
- pd.crosstab(titanic.sex, titanic.pclass)
- plt.figure(figsize=(12,8))
- sns.set(font_scale=1.4)
- sns.heatmap(pd.crosstab(titanic.sex, titanic.pclass), annot= True, fmt = "d", cmap = "Reds", vmax = 150)
- plt.show()
- pd.crosstab(titanic.sex, titanic.pclass, values= titanic.survived, aggfunc= "mean")
- plt.figure(figsize=(12,8))
- sns.set(font_scale=1.4)
- sns.heatmap(pd.crosstab(titanic.sex, titanic.pclass, values= titanic.survived, aggfunc= "mean"), annot= True, cmap = "Reds")
- plt.show()
- titanic.corr()
- plt.figure(figsize=(12,8))
- sns.set(font_scale=1.4)
- sns.heatmap(titanic.corr(), annot= True, cmap = "Reds")
- plt.show()
- #########################################################################################################################
- # Seaborn pairplot
- plt.figure(figsize=(12,8))
- sns.set(font_scale=1.4)
- sns.pairplot(cars, kind = 'scatter')
- plt.show()
- sns.set(font_scale=1.5)
- sns.pairplot(data = cars[["gpm", "horsepower", "origin"]], kind = "scatter", hue = "origin", aspect = 2, height = 3)
- plt.show()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement