yhat/ggplot — pull request #348 by matthias-k (2014-07-22 13:30:38+00:00)
Title: Stat summary

Hi,

I implemented the stat `stat_summary` (http://docs.ggplot2.org/current/stat_summary.html). I also implemented the default functions that are provided in R, i.e. `mean_cl_boot`, `mean_cl_normal`, `mean_sdl`, `median_hilow` and `mean_se`. As the syntax `fun.data = 'mean_cl_boot'` is not valid in python, I changed it to `fun_data = ...`.

Besides these predefined functions that can be given as string, one can provide arbitrary functions that take a series and return a series containing `y`, `ymin` and `ymax` (for `fun_data`) resp. a scalar (for `fun_y`, `fun_ymin` and `fun_ymax`). Examples are provided in the docstring.

At the moment, these functions `mean_cl_boot` etc. are implemented in `ggplot/stats/stat_summary.py`. Probably it is a good idea to move them somewhere else to make them available easier in case one wants to change the default parameters. But I am not sure where the right place for them would be. I will add tests for these functions too, as soon as they are at their final place. For stat_summary, I already wrote tests.

### Example

from ggplot import *
ggplot(aes=(x='cut', y='carat'), data=diamonds) + stat_summary(fun_data = 'mean_cl_boot')

![default](https://cloud.githubusercontent.com/assets/4093707/3658465/e1ec74ae-11a3-11e4-82b2-61561b3a2a38.png)