pivot table pie plots

This commit is contained in:
Benjamin Bertrand
2017-03-08 22:23:19 +03:00
parent 1ca9a45550
commit ac4040641c
2 changed files with 40 additions and 14 deletions

View File

@@ -1,15 +1,16 @@
#!/usr/bin/env python
# encoding: utf-8
from .plottings import radar_graph
from .plottings import radar_graph, pivot_table_to_pie
from .skills_tools import count_levels, count_skill_evaluation
import matplotlib.pyplot as plt
import pandas as pd
import numpy as np
import logging
logger = logging.getLogger(__name__)
__all__ = ["radar_on",
"pie_skill_evaluation",
"pies_skills_level",
"pie_pivot_table",
"marks_hist",
"parallele_on",
]
@@ -33,18 +34,16 @@ def radar_on(df, index, optimum = None):
fig, ax = radar_graph(labels, values, optimum)
return fig, ax
def pie_skill_evaluation(df, skill):
""" Plot a pie plot with the repartition of skill evaluations
"""
ax = count_skill_evaluation(df, skill).plot.pie(autopct='%.0f')
return ax
def pie_pivot_table(df, pies_per_lines = 3, **kwargs):
""" Plot a pie plot of the pivot_table of df
def pies_skills_level(df, skill):
""" Plot series of pies (one by different skill) with level repartition """
levels_counts = count_levels(df, skill)
fig, ax = plt.subplots(nrows=1, ncols=len(levels_counts), figsize=(16,3))
plots = levels_counts.T.plot(ax=ax ,kind="pie", subplots=True, legend=False)
return fig, ax
:param df: the dataframe.
:param pies_per_lines: Number of pies per line.
:param kwargs: arguments to pass to pd.pivot_table.
"""
logger.debug(f"pie_pivot_table avec les arguments {kwargs}")
pv = pd.pivot_table(df, **kwargs)
return pivot_table_to_pie(pv, pies_per_lines)
def marks_hist(df):
""" Return axe for the histogramme of the dataframe