Skip to content

Instantly share code, notes, and snippets.

@jmcarp
Created March 9, 2013 17:18
Show Gist options
  • Save jmcarp/5124886 to your computer and use it in GitHub Desktop.
Save jmcarp/5124886 to your computer and use it in GitHub Desktop.
Basic boxplot with dots.
# Import matplotlib
from matplotlib import pyplot as plt
# Define data
data_grp1 = [1, 2, 3, 4, 5, 3, 2, 1, 5, 6, 4, 2, 4]
data_grp2 = [6, 7, 8, 7, 8, 9, 1, 1, 9, 15]
# Boxplot
plt.boxplot([data_grp1, data_grp2])
# Dots
plt.plot([1] * len(data_grp1), data_grp1, 'o')
plt.plot([2] * len(data_grp2), data_grp2, 'o')
# Show plot
plt.show()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment