VIS: Hide labels for NaN/zeros in boxplt [WIP]
State: closed

Closes: https://github.com/pydata/pandas/issues/8198

The idea is to hide the labels around the pie plot so they don't overlap w/ nonzero labels. The NaN/zero labels should still be visible in the legend to indicate that there's missing data. There's a picture of the problem in the linked issue.

NaNs in the top row of plots:

```
In [1]: df = pd.DataFrame(np.random.rand(4, 4))

In [2]: df2 = df.copy()

In [3]: for i in range(len(df)):
   ...:     df.iloc[i, i] = np.nan
   ...:     

In [4]: fig, axes = plt.subplots(figsize=(16, 8), nrows=2, ncols=4)

In [5]: df.plot(kind='pie', subplots=True, ax=axes.ravel()[:4])
In [6]: df2.plot(kind='pie', subplots=True, ax=axes.ravel()[4:])
```

![ex](https://cloud.githubusercontent.com/assets/1312546/4320249/881bf944-3f35-11e4-85c8-bb5c4d539435.png)

Right now, for **DataFrames only** the NaN/zero labels aren't being put in the legend (or they aren't showing up). Still need to figure out why. It works fine for Series:

```
In [8]: df[0].plot(kind='pie', figsize=(4,4), legend=True)
```

![ex2](https://cloud.githubusercontent.com/assets/1312546/4320269/b75df6ee-3f35-11e4-9774-50f8aed26594.png)


Labels:
name: Visualization
description: plotting
name: Missing-data
description: np.nan, pd.NaT, pd.NA, dropna, isnull, interpolate

Comments:
So it's not DataFrames that's the problem with the missing labels per-se, it's the interaction of subplots and legend.

``` python
In [11]: df[0].plot(kind='pie', subplots=True, legend=True, ax=axes[0][0])
```

@sinhrks I'm looking at `_make_legend`, Do you know offhand why the `elif self.subplots and self.legend:` branch doesn't have all the handles, labels, and title handling that the non-subplots branch has?

``` python
        # from _make_legend()
        if not self.subplots:
            if not leg is None:
                title = leg.get_title().get_text()
                handles = leg.legendHandles
                labels = [x.get_text() for x in leg.get_texts()]

            if self.legend:
                if self.legend == 'reverse':
                    self.legend_handles = reversed(self.legend_handles)
                    self.legend_labels = reversed(self.legend_labels)

                handles += self.legend_handles
                labels += self.legend_labels
                if not self.legend_title is None:
                    title = self.legend_title

            if len(handles) > 0:
                ax.legend(handles, labels, loc='best', title=title)

        elif self.subplots and self.legend:
            for ax in self.axes:
                ax.legend(loc='best')
```

I'll play with it and see what breaks.

Ahh of course, because that would duplicate every label for each axes in the subplots. Let me see if there's an easy fix. Or we may have to live with this for now.

I think our methods handling legends and labels need to be subplot-aware. Then instead of storing everything in a flat list like:

``` python
ipdb> self.legend_labels
['0', '1', '2', '3', '0', '1', '2', '3', '0', '1', '2', '3', '0', '1', '2', '3']
```

It will be a list of tuples, grouped by axes. I'd like to do this before 0.15, so that we can get all the NaN plotting stuff squared away at the same time.

I've looked at this a bit more this morning. It seems like a pretty big refactor for a pretty minor benefit, especially when the recommendation for plotting is to use seaborn or bokeh.

Any objections to merging this as is? Just as a reminder:
- We'd like for all the labels (including NaN/0's) to show up in the legend
- They aren't added when `subplots=True` (DataFrames)

as a side note - why don't we create an issue to add in a section showing plotting (basic stuff prob) with seaborn/bokeh/ggplot ? 

and/or more prominent links in the plotting docs?

Ok Merging this. Followup on the subplots NaN legend in https://github.com/pydata/pandas/issues/8390

I broke something https://travis-ci.org/pydata/pandas/builds/36275924