From d801d29dcb60c99615b9d5e81f083a5669340365 Mon Sep 17 00:00:00 2001 From: Benjamin Bertrand Date: Thu, 9 Mar 2017 14:01:52 +0300 Subject: [PATCH] Solve bug with multiple ax on same fig --- notes_tools/tools/marks_plottings.py | 5 +++-- notes_tools/tools/plottings.py | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/notes_tools/tools/marks_plottings.py b/notes_tools/tools/marks_plottings.py index 8e01c6a..f82796c 100644 --- a/notes_tools/tools/marks_plottings.py +++ b/notes_tools/tools/marks_plottings.py @@ -45,15 +45,16 @@ def pie_pivot_table(df, pies_per_lines = 3, **kwargs): pv = pd.pivot_table(df, **kwargs) return pivot_table_to_pie(pv, pies_per_lines) -def marks_hist(df): +def marks_hist(df, **kwargs): """ Return axe for the histogramme of the dataframe :param df: Dataframe with "Mark" and "Bareme" columns. If it has "Nom" column, it is use in title. + :param kwargs: argument to pass to hist """ bareme = df["Bareme"].max() bins = int(bareme*2) - ax = df["Mark"].hist(bins = bins, range=(0,bareme)) + ax = df["Mark"].hist(bins = bins, range=(0,bareme), **kwargs) try: nom = df["Nom"].unique() diff --git a/notes_tools/tools/plottings.py b/notes_tools/tools/plottings.py index 54c4a21..8d3363f 100644 --- a/notes_tools/tools/plottings.py +++ b/notes_tools/tools/plottings.py @@ -81,7 +81,7 @@ def my_autopct(values): def pivot_table_to_pie(pv, pies_per_lines = 3): nbr_pies = len(pv.columns) nbr_cols = min(pies_per_lines, nbr_pies) - nbr_rows = max(nbr_pies % nbr_cols,1) + nbr_rows = nbr_pies // nbr_cols + 1 f, axs = plt.subplots(nbr_rows, nbr_cols, figsize = (4*nbr_cols,4*nbr_rows)) for (c, ax) in zip(pv, axs.flatten()): datas = pv[c]