Plot stats grouped by test capacitor load _and_ frequency.

    In other words, we calculate the mean of all samples in the data
    frame for each test capacitance and frequency pairing, plotting
    the following stats:

     - Root mean squared error
     - Coefficient of variation
     - Bias

    ## [Coefficient of variation][1] ##

    > In probability theory and statistics, the coefficient of
    > variation (CV) is a normalized measure of dispersion of a
    > probability distribution or frequency distribution. It is defined
    > as the ratio of the standard deviation to the mean.

    [1]: http://en.wikipedia.org/wiki/Coefficient_of_variation

def plot_stat_summary(df, fig=None):
    '''
    Plot stats grouped by test capacitor load _and_ frequency.

    In other words, we calculate the mean of all samples in the data
    frame for each test capacitance and frequency pairing, plotting
    the following stats:

     - Root mean squared error
     - Coefficient of variation
     - Bias

    ## [Coefficient of variation][1] ##

    > In probability theory and statistics, the coefficient of
    > variation (CV) is a normalized measure of dispersion of a
    > probability distribution or frequency distribution. It is defined
    > as the ratio of the standard deviation to the mean.

    [1]: http://en.wikipedia.org/wiki/Coefficient_of_variation
    '''
    if fig is None:
        fig = plt.figure(figsize=(8, 8))

    # Define a subplot layout, 3 rows, 2 columns
    grid = GridSpec(3, 2)
    stats = calculate_stats(df, groupby=['test_capacitor',
                                         'frequency']).dropna()

    for i, stat in enumerate(['RMSE %', 'cv %', 'bias %']):
        axis = fig.add_subplot(grid[i, 0])
        axis.set_title(stat)
        # Plot a colormap to show how the statistical value changes
        # according to frequency/capacitance pairs.
        plot_colormap(stats, stat, axis=axis, fig=fig)
        axis = fig.add_subplot(grid[i, 1])
        axis.set_title(stat)
        # Plot a histogram to show the distribution of statistical
        # values across all frequency/capacitance pairs.
        try:
            axis.hist(stats[stat].values, bins=50)
        except AttributeError:
            print stats[stat].describe()
    fig.tight_layout()