ENH/VIS: Area plot is now supported by kind='area'. 
State: closed

Area plot is added to plotting method. The AreaPlot class is created as a subclass of LinePlot, thus it works also in time series. 

By default, area plot is being stacked. When area plot is not stacked (`stacked=False`), alpha value is set to 0.5 to show overlapped area if not configured specifically. As a side benefit, line plot also can be stacked by specifying `stacked=True` (disabled by default). Different from stacked bar plot, I don't know good visualization for positive/negative mixed data. Thus, input must be all positive or all negative when `stacked=True`. I'll try to implement it if there is a good way. Also, area plot doesn't support logy and loglog plot because filling area starts from 0.

Note: Area plot's legend is implemented based on the answer described in:
http://stackoverflow.com/questions/14534130/legend-not-showing-up-in-matplotlib-stacked-area-plot

_Example:_
![figure_1](https://f.cloud.github.com/assets/1696302/2436288/dee8f4e6-add8-11e3-9297-a7403935844d.png)


Labels:
name: Bug
name: Visualization
description: plotting

Comments:
You can put an example in `doc/source/visualization.rst` if you want to show off your work.

One thing case that your implementation doesn't allow is stacked with mixed positive and negatives, where every value in a column are either _all_ positive or _all_ negative. I think this would make sense visually. We can leave that for a future issue if you want.

Thanks. I've added examples in `visualization.rst`, and answered above comments.

Sure. Done it. 

There are other version descriptions which uses italic in 455, 468, 487th lines. Shall I modify it as the same manner?

Failed in `test_frame_groupby_plot_boxplot` which is not modified.  Maybe the same issue as #6670? I'll hook Travis again.

@sinhrks can you rebase

@TomAugspurger @jorisvandenbossche ok with this?

Rebased. Could you check #6678 first, because I'll apply the same fix to area plot.

The way you've done it makes gives some strange results if someone does multiple area plots on the same axis (I can't think of a reason _why_ anyone would want to do this, but who knows).

``` python
In [64]: df
Out[64]: 
     0   1   2
0    0   1   3
1    1   2   7
2    1   6   8
3    5  10   8
4    5  11   8
5    9  15  11
6    9  19  15
7   12  20  17
8   15  20  19
9   16  25  20
10  17  27  21
11  21  30  25
12  21  30  28
13  25  31  30
14  25  32  34
15  28  34  35
16  29  38  38
17  30  38  42
18  34  38  44
19  38  38  48

[20 rows x 3 columns]

In [65]: df2 = df + 10

In [66]: ax = df.plot(kind='area')

In [67]: df2.plot(kind='area', ax=ax)
Out[67]: <matplotlib.axes.AxesSubplot at 0x10f603250>
```

The original shading is removed:
![area](https://cloud.githubusercontent.com/assets/1312546/2760507/107bf908-c9b9-11e3-8434-4f55abc52a6c.png)

Honestly, I think I'm OK with this. Unless someone can think of any reason where multiple, independently stacked datasets on the same axes makes sense.

That's all my comments. The biggest one is deciding how to handle NaNs. Thoughts? `line` leaves gaps (which doesn't really make sense for area, does it?), `scatter` and `hexbin` excludes those rows with NaNs (which is an option), `bar` essentially draws a bar of length 0 (which isn't an option)

Thanks for all your comments.

### Multiple area plots on single axes:

Actually it is not deleted. When `staked=True`, alpha value 1.0 is used because it was considered each area will not be overlapped. This makes previous area hidden when plotting new area on the same axes. One option is always use `alpha=0.5` in area plot unless otherwise specified.

If you pass `alpha` explicitly, you can see all the area are drawn.

```
import numpy as np
import matplotlib.pyplot as plt
import pandas.util.testing as tm
t_df = DataFrame(np.random.rand(6, 3),
               index=tm.makeDateIndex(k=6), columns=['a', 'b', 'c'])
t_df2 = DataFrame(np.random.rand(6, 3),
               index=tm.makeDateIndex(k=6), columns=['x', 'y', 'z'])

fig, axes = plt.subplots(1, 1, figsize=(14, 8))
plt.subplots_adjust(top=0.9, bottom=0.2, left=0.15, right=0.9, hspace=0.5)
t_df.plot(kind='area', ax=axes, alpha=0.5)
t_df2.plot(kind='area', ax=axes, alpha=0.5)
```

![figure_1](https://cloud.githubusercontent.com/assets/1696302/2807970/484a3a18-cd04-11e3-8de0-065553caecbe.png)

### Handling NaN:

It looks MPL `stackplot` doesn't care `NaN` (right figure). I think automatically filling by 0 is preferable (left figure).  How about the following spec?:
- Line plot without stacking: skip `NaN` and split lines (no change).
- Line plot with stacking: fill `NaN` with 0 (for stacking purpose)
- Area plot: fill `NaN` with 0 (for stacking/filling purpose)

```
import matplotlib.pyplot as plt
fig, axes = plt.subplots(1, 2)

x = range(6)
y11 = [1, 1, 0, 1, 1, 1]
y12 = [2, 2, 2, 0, 2, 2]
axes[0].stackplot(x, y11, y12)

y21 = [1, 1, np.nan, 1, 1, 1]
y22 = [2, 2, 2, np.nan, 2, 2]
axes[1].stackplot(x, y21, y22)
```

![figure_2](https://cloud.githubusercontent.com/assets/1696302/2807957/08e17360-cd03-11e3-984d-913d463febb4.png)

Also, I noticed that initial description was incorrect. Each line/area can be stacked on positive/negative direction separately if each columns are all either positive or negative. No need to all the data is either positive or negative. I've changed the logic, and will add some tests/docs for this.

> Different from stacked bar plot, I don't know good visualization for positive/negative mixed data. Thus, input must be all positive or all negative when stacked=True.

```
import numpy as np
import pandas.util.testing as tm

df = pd.DataFrame({'a': np.random.rand(6),
                'b': np.random.rand(6),
                'c': - np.random.rand(6),
                'd': - np.random.rand(6)},
               index=tm.makeDateIndex(k=6))
df.plot(kind='area', stacked=True)
```

![figure_3](https://cloud.githubusercontent.com/assets/1696302/2807988/a5d75a38-cd06-11e3-8bae-1ab3951e3116.png)

I've added tests for fixed `NaN` handling and stacking, and modified doc. I think remainings are:
- What the default `alpha` should be.
- Whether `NaN` handling described above looks OK.

I think a default alpha of 1 when stacked and .5 when not stacked is good.

Your `NaN` handling looks good too, especially since it's consistent with how matplotlib does it.

Good catch on the all positive / all negative checks by column.

I'm reviewing now. Should be able to merge this today.

@sinhrks ping me when you rebase.

@sinhrks @TomAugspurger 

Looks like there was a Yahoo failure, I restarted the build.

this is fine, I already fixed master