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

@ -6,6 +6,7 @@ import numpy as np
from notes_tools.tools.marks_plottings import (pie_pivot_table, from notes_tools.tools.marks_plottings import (pie_pivot_table,
parallel_on, parallel_on,
radar_on, radar_on,
hist_boxplot
) )
import seaborn as sns import seaborn as sns
@ -187,6 +188,16 @@ class Classe(object):
self.exo_df = exo_df self.exo_df = exo_df
self.eval_df = eval_df self.eval_df = eval_df
@property
def desription(self):
""" Desribe on marks """
# TODO: not working... |ven. mars 31 18:48:17 EAT 2017
try:
self._description
except AttributeError:
self._description = self.eval_df["Mark"].describe()
return self._description
@property @property
def marks_tabular(self): def marks_tabular(self):
""" Latex tabular with marks of students""" """ Latex tabular with marks of students"""
@ -197,6 +208,15 @@ class Classe(object):
self._marks_tabular.columns = ["Élèves", "Note"] self._marks_tabular.columns = ["Élèves", "Note"]
return self._marks_tabular.to_latex() return self._marks_tabular.to_latex()
@property
def hist_boxplot(self):
""" Marks histogram and associed box plot """
try:
self._hist_boxplot
except AttributeError:
self._hist_boxplot = hist_boxplot(self.eval_df)
return self._hist_boxplot
@property @property
def level_heatmap(self): def level_heatmap(self):
""" Heapmap on acheivement level """ """ Heapmap on acheivement level """

View File

@ -67,6 +67,27 @@ def marks_hist(df, **kwargs):
return ax 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): def parallel_on(df, index, student=None):
""" Plot parallel one line by student """ Plot parallel one line by student