Solve bug with multiple ax on same fig

This commit is contained in:
Benjamin Bertrand 2017-03-09 14:01:52 +03:00
parent ac4040641c
commit d801d29dcb
2 changed files with 4 additions and 3 deletions

View File

@ -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()

View File

@ -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]