10 Distributions
10.1 Bar Plots
10.1.1 A simple bar plot
|>
df ggplot(aes(gen_health)) +
geom_bar(color = "red")
="gen_health", color="grey", edgecolor="red", data=df) sns.countplot(x
10.1.2 A stacked bar plot
|>
df ggplot(aes(gen_health, fill = heart_disease)) +
geom_bar()
="gen_health", hue="heart_disease", multiple="stack", aspect=7/5, data=df);
sns.displot(x plt.show()
10.1.3 A dodged bar plot
|>
df ggplot(aes(gen_health, fill = heart_disease)) +
geom_bar(position = "dodge")
="gen_health", hue="heart_disease", data=df) sns.countplot(x
10.2 Histograms
|>
df ggplot(aes(bmi)) +
geom_histogram()
`stat_bin()` using `bins = 30`. Pick better value with `binwidth`.
="bmi", data=df) sns.histplot(x
10.3 Density Plots
|>
df ggplot(aes(bmi)) +
geom_density()
="bmi", data=df) sns.kdeplot(x
10.4 Boxplots
|>
df ggplot(aes(smoking, bmi)) +
geom_boxplot()
="smoking", y="bmi", data=df) sns.boxplot(x
10.5 Violin Plots
|>
df ggplot(aes(smoking, bmi)) +
geom_violin()
="smoking", y="bmi", data=df) sns.violinplot(x