BUG: Fixed plot label shows as None. #8905
State: closed

Fixes https://github.com/pydata/pandas/issues/8905


Labels:
name: Bug
name: Visualization
description: plotting

Comments:
@TomAugspurger another plotting one

@papaloizouc pls add a release not in v0.15.2 as well (in bug fix section)

May need some help on this one. `test_graphics.TestDataFramePlots.test_boxplot` expects a warning `No labelled objects found. Use label='...' kwarg on individual plots.` When i run the test or the test case individually it passes. But when i run all tests it fails. I am a bit lost. Might be because of 

```
if __name__ == '__main__':
    nose.runmodule(argv=[__file__, '-vvs', '-x', '--pdb', '--pdb-failure'],
                   exit=False)
```

```
nosetests pandas/tests/test_graphics.py:TestDataFramePlots.test_boxplot
Ran 1 test in 1.981s
OK
```

```
 nosetests pandas/tests/test_graphics.py:TestDataFramePlots
Ran 82 tests in 94.078s
OK (SKIP=5)
```

```
 nosetests
FAIL: test_boxplot (pandas.tests.test_graphics.TestDataFramePlots)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/foobar/dev/pandas/pandas/tests/test_graphics.py", line 1839, in test_boxplot
    subplots=True, logy=True)
  File "/usr/lib/python2.7/contextlib.py", line 24, in __exit__
    self.gen.next()
  File "/home/foobar/dev/pandas/pandas/util/testing.py", line 1674, in assert_produces_warning
    % expected_warning.__name__)
AssertionError: Did not see expected warning of class 'UserWarning'.
```

@jreback sorry forgot to add it in the tag will keep in mind on the next one

I'll try to look soon. @papaloizouc does the warning occur when you run this from the interpreter?

@TomAugspurger yeah i was closer on this yesterday i think i can fix this soon but i still didn't figure out what is wrong with the tests. i removed the `if __main__` but still the tests pass unless i run all of them. If you want i can make a different ticket for the tests.

Great. I'll checkout your branch and see if I can figure out the warning test tonight or tomorrow.

@TomAugspurger ?

@papaloizouc can you rebase on master and push again (the build failure should be fixed I think)

@jreback i did rebase still failing but when i try it in ipython it looks like the warning shows only the first time i generate the plot. For the first time i can see the same warning in master and my branch. I am not exactly sure what went wrong tho because the test was not failing before.

The code i use is:

```
import pandas as pd
import matplotlib.pyplot as plt
import pandas.io.data as web
import matplotlib as mpl
import pandas.util.testing as tm
import numpy as np
import pandas.core.common as com


n = 100
gender = tm.choice(['Male', 'Female'], size=n)
classroom = tm.choice(['A', 'B', 'C'], size=n)

hist_df = pd.DataFrame({'gender': gender,
                          'classroom': classroom,
                           'height': random.normal(66, 4, size=n),
                           'weight': random.normal(161, 32, size=n),
                           'category': random.randint(4, size=n)})

df = hist_df
series = df['height']
numeric_cols = df._get_numeric_data().columns
labels = [com.pprint_thing(c) for c in numeric_cols]
df.plot(kind='box', subplots=True, logy=True)
```

And i get 

```
/home/foobar/dev/venvs/pandas_venv/local/lib/python2.7/site-packages/matplotlib/axes/_axes.py:476: UserWarning: No labelled objects found. Use label='...' kwarg on individual plots.
  warnings.warn("No labelled objects found. "
```

warnings only show once (for a test)

@TomAugspurger @jorisvandenbossche pls merge or bump asap (obviously needs fixing though)

sorry guys i couldn't figure out what went wrong with tests, i get the warning running the single test and running in ipython. spent a lot of time on this but couldn't figure it out.

It seems that this has been fixed in the meantime by #9574, so closing this