Add hist_boxplot to ClassPOV

This commit is contained in:
Benjamin Bertrand
2017-03-31 19:01:10 +03:00
parent b761f47da9
commit 15cf2002ab
2 changed files with 41 additions and 0 deletions

View File

@@ -67,6 +67,27 @@ def marks_hist(df, **kwargs):
return ax
def hist_boxplot(df, kwargs_hist=[], kwargs_box=[]):
f, (ax_hist, ax_box) = plt.subplots(2, sharex=True,
gridspec_kw={"height_ratios": (.85, .15)})
marks_hist(df, ax = ax_hist, rwidth=0.9)
ev_desc = df["Mark"].describe()
m = ev_desc["mean"]
ax_hist.plot([m,m], ax_hist.get_ylim())
ax_hist.annotate(round(ev_desc["mean"],1),
xy=(ev_desc["mean"] + 0.2, ax_hist.get_ylim()[1]-0.2))
df["Mark"].plot.box(ax = ax_box, vert=False, widths = 0.6)
ax_box.set_yticklabels("")
for e in ["min", "25%", "50%", "75%", "max"]:
ax_box.annotate(ev_desc[e],
xy=(ev_desc[e] - 0.2, ax_box.get_ylim()[1]))
return f, (ax_hist, ax_box)
def parallel_on(df, index, student=None):
""" Plot parallel one line by student