ENH/BUG: boxplot now supports layout
State: closed

Closes #6769. Added `layout` kw to `boxplot`. I think tests can be improved if boxplot can return ndarray with the same shape as layout, as the same manner as hist (maybe after #4472).
## Bug fix

It includes the fix to hide unnecessary axes than required in boxplot and hist. For example, `layout=(2, 2)` is specified for 3 subplots. I've listed affected cases as below.

```
import pandas as pd
import numpy as np

df = pd.DataFrame({'3g': 'A A A B B B C C C'.split(),
                   '2g': [1, 2, 1, 2, 1, 2, 1, 2, 2],
                   'values': np.random.rand(9), 
                   'values2': np.random.rand(9),
                   'values3': np.random.rand(9)})
# BoxPlot

# specify 3 columns with by keyword -> should be 3 axes in (2, 2) layout
df.boxplot(column=['values', 'values2', 'values3'], by='2g')

# groupby results in 3 groups -> should be 3 axes 
df.groupby('3g').boxplot()

# groupby results in 3 groups, with column kw -> should be 3 axes in (2, 2) layout
df.groupby('3g').boxplot(column=['values', 'values2', 'values3'])

# Histogram

# specify 3 columns without by kw -> should be 3 axes in (2, 2) layout
df.hist(column=['values', 'values2', 'values3'])

# groupby results 3 groups results of by kw -> should be 3 axes in (2, 2) layout
df.hist(column=['values'], by='3g')
# This results KeyError: '3g' in current master, and the error has been fixed.

# groupby results in 3 groups -> should be 3 axes in (2, 2) layout
df.hist(by='3g')

# layout contains more size than groups -> should be 2 axes in specified layout
df.hist(by='2g', layout=(2, 2))
```


Labels:
name: Bug
name: Visualization
description: plotting

Comments:
I haven't  attached sample data. Modified.

@sinhrks is this different than #6991 ?

@TomAugspurger 

@jreback Different. #6991 is to specify the target ax / figure for `_subplots`. This one is to specify the layout to be created by `_supblots`. 

rebase

@TomAugspurger ok by u?

For the first example `df.boxplot(column=['values', 'values2', 'values3'], by='2g')`, this is what I see
![boxplot](https://cloud.githubusercontent.com/assets/1312546/2936153/28916e8e-d84a-11e3-897e-40382705e57f.png)

(The box plots are draw in master)

Strange. I can find no logic to hide unnecessary axes in `_grouped_plot_by_column` in current master, and additional axes in bottom-left when I try. (Unrelated to the issue, but I've increased data to plot box cleary). 
![figure_1](https://cloud.githubusercontent.com/assets/1696302/2936180/e96d55ea-d84b-11e3-9b88-5a007b8e0b3d.png)

Sorry if I was unclear. that picture was from your PR.

This is what I see on master:
![master](https://cloud.githubusercontent.com/assets/1312546/2936403/1f722b08-d85a-11e3-8d6f-a21afb04f898.png)

So your PR is correctly hiding the lower right box. I just wasn't sure why the boxplots weren't draw on my first picture.

But it looks like it was just a scaling issue. Setting an axes `ylim` manually after plotting gets it correct.

You may want to look into how the `ylim` is set and see if you can get a better default.

This is fine by me, pending that setting of the plot limits.

Thanks to confirm. I misunderstood that you're referring to axes issue. Maybe limit issue is the same as #5517?

Is there anything should be confirmed in this PR?

My mistake. I have matplotlib 1.4 on that other environment. This PR is good!

Merged via ebc4fedee2039

I kinda messed up the merge commit. I `add`ed my fix on the release conflict instead of `continue`ing. So now we'll have

```
ebc4fed release conflict
49f3616 Merge pull request #7041 from sinhrks/unstack
```

in the history. @jreback is that OK?

yeh it didn't presever the original one. no biggie though.

@sinhrks FWIW [seaborn](http://www.stanford.edu/~mwaskom/software/seaborn/) handles these kinds of things almost trivially and allows for much prettier plots than pandas does. [`FacetGrid`](http://www.stanford.edu/~mwaskom/software/seaborn/tutorial/axis_grids.html) is especially neat, and so far it hasn't let me down. I guess I'm just kind of down on pandas plotting lately since there seems to be a fair number of quality plotting libraries out there that handle all the annoying details. Layout, color cycling, and plotting by multiple groups come to mind. In addition, most of the seaborn plots that can be called on individual columns or column names can be called with `FacetGrid`. Finally, you can call most of the matplotlib pyplot functions like plot and hist on `FacetGrid`. This has effectively nullified me using any of the pandas plotting methods (I used to use them for "quick" analyses, but seaborn is much faster at getting to a useful result). Ok, I'm done