Skip to content

Instantly share code, notes, and snippets.

@GeorgeSeif
Created March 1, 2018 20:20
Show Gist options
  • Save GeorgeSeif/3056d585140acfc2a05816c39569255e to your computer and use it in GitHub Desktop.
Save GeorgeSeif/3056d585140acfc2a05816c39569255e to your computer and use it in GitHub Desktop.
def boxplot(x_data, y_data, base_color="#539caf", median_color="#297083", x_label="", y_label="", title=""):
_, ax = plt.subplots()
# Draw boxplots, specifying desired style
ax.boxplot(y_data
# patch_artist must be True to control box fill
, patch_artist = True
# Properties of median line
, medianprops = {'color': median_color}
# Properties of box
, boxprops = {'color': base_color, 'facecolor': base_color}
# Properties of whiskers
, whiskerprops = {'color': base_color}
# Properties of whisker caps
, capprops = {'color': base_color})
# By default, the tick label starts at 1 and increments by 1 for
# each box drawn. This sets the labels to the ones we want
ax.set_xticklabels(x_data)
ax.set_ylabel(y_label)
ax.set_xlabel(x_label)
ax.set_title(title)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment