Skip to content

Instantly share code, notes, and snippets.

@cereniyim
Created January 8, 2020 13:02
Show Gist options
  • Save cereniyim/df1c8646411cc34eb9720a79400a200f to your computer and use it in GitHub Desktop.
Save cereniyim/df1c8646411cc34eb9720a79400a200f to your computer and use it in GitHub Desktop.
Distribution plot with mean and median
# set the plot size
figsize(14,10)
# set the histogram, mean and median
sns.distplot(trees["Cover_Type"], kde=False)
plt.axvline(x=trees.Cover_Type.mean(), linewidth=3, color='g', label="mean", alpha=0.5)
plt.axvline(x=trees.Cover_Type.median(), linewidth=3, color='y', label="median", alpha=0.5)
# set title, legends and labels
plt.xlabel("Cover_Type")
plt.ylabel("Count")
plt.title("Distribution of Trees/Labels/Cover_Types", size=14)
plt.legend(["mean", "median"])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment