Skip to content

Instantly share code, notes, and snippets.

@tanveer-sayyed
Last active February 13, 2019 08:32
Show Gist options
  • Save tanveer-sayyed/e8d95749416b2df6b8f63ee124b7b73b to your computer and use it in GitHub Desktop.
Save tanveer-sayyed/e8d95749416b2df6b8f63ee124b7b73b to your computer and use it in GitHub Desktop.
In [24]:
original = [1, 1, 1, 1, 2, 2, 2, 2, 3, 3] # removing NaNs
replaced_by_mean = [1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 1.8, 1.8, 1.8, 1.8, 1.8]
replaced_by_proportion = [1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 1, 1, 2, 2, 3]
plt.figure(figsize=(10,6))
plt.subplot(3, 1, 1)
plt.boxplot(original, showmeans=True, vert=False)
plt.title('original', color='green')
plt.subplot(3, 1, 2)
plt.boxplot(replaced_by_mean, showmeans=True, vert=False)
plt.title('replaced_by_mean', color='blue')
plt.subplot(3, 1, 3)
plt.boxplot(replaced_by_proportion, showmeans=True, vert=False)
plt.title('replaced_by_proportion', color='magenta')
plt.tight_layout()
plt.show()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment