FIX: fix cleanup warnings for errorbar timeseries
State: closed

- [ ] closes #xxxx
- [ ] tests added / passed
- [ ] passes `black pandas`
- [ ] passes `git diff upstream/master -u -- "*.py" | flake8 --diff`
- [ ] whatsnew entry

Currently in ``pandas/tests/plotting/tests_frame.py`` there are several warnings emitted.

```
pandas/tests/plotting/test_frame.py::TestDataFramePlots::test_mpl2_color_cycle_str
  /workspaces/pandas/pandas/plotting/_matplotlib/style.py:64: MatplotlibDeprecationWarning: Support for uppercase single-letter colors is deprecated since Matplotlib 3.1 and will be removed in 3.3; please use lowercase instead.
    [conv.to_rgba(c) for c in colors]

pandas/tests/plotting/test_frame.py::TestDataFramePlots::test_errorbar_plot
pandas/tests/plotting/test_frame.py::TestDataFramePlots::test_errorbar_plot
pandas/tests/plotting/test_frame.py::TestDataFramePlots::test_errorbar_plot
pandas/tests/plotting/test_frame.py::TestDataFramePlots::test_errorbar_timeseries
pandas/tests/plotting/test_frame.py::TestDataFramePlots::test_errorbar_timeseries
pandas/tests/plotting/test_frame.py::TestDataFramePlots::test_errorbar_timeseries
  /workspaces/pandas/pandas/plotting/_matplotlib/__init__.py:61: UserWarning: To output multiple subplots, the figure containing the passed axes is being cleared
    plot_obj.generate()

-- Docs: https://docs.pytest.org/en/stable/warnings.html
```

This PR handles warnings in ``test_errorbar_timeseries``.
If this approach is considered reasonable by the reviewers, then I will do the same for ``test_errorbar_plot`` as well as other similar warnings among the plotting-related tests.

Labels:
name: Testing
description: pandas testing functions or related to the test suite
name: Visualization
description: plotting
name: Clean

Comments:
so the test itself was causing the warnings?
cc @charlesdong1991 
> 
> 
> so the test itself was causing the warnings?

Yes, the test itself was causing the warning.
this reminds me of this https://github.com/pandas-dev/pandas/pull/13188 issue, the warning and the issue looks the same, should we use `with tm.assert_produces_warning(UserWarning):` to catch the part where `subplots=True`, something like this? and remove the `catch_warning` on the very top?

```python
with tm.assert_produces_warning(UserWarning):
    axes = _check_plot_works(tdf.plot, kind=kind, yerr=tdf_err, subplots=True)
    self._check_has_errorbars(axes, xerr=0, yerr=1)
```
> 
> 
> this reminds me of this #13188 issue, the warning looks the same, should we use `with tm.assert_produces_warning(UserWarning):` to catch the part where `subplots=True`? or we should also use the same solution here to replace these warnings?

I did not use ``tm.assert_produces_warning`` because there is no way to match warning message this way.
I believe it is reasonable to match the message here.
What would others think?
true, I would suggest to use `tm.assert_produce_warning` here to align with other existing similar issue, and see if we could add an arg for `tm.assert_produce_warning` to also match the warning message (I haven't looked at how this function is structured, not sure if it's easy or not to add such match), and then do a small refactor to match the warning message in these places.

does it sound good to you?

> 
> 
> true, I would suggest to use `tm.assert_produce_warning` here to align with other existing similar issue, and see if we could add an arg for `tm.assert_produce_warning` to also match the warning message (I haven't looked at how this function is structured, not sure if it's easy or not to add such match), and then do a small refactor to match the warning message in these places.
> 
> does it sound good to you?

Absolutely, I will refactor to ``tm.assert_produces_warning`` and add a comment what kind of warning message is expected.
Then in a follow-on PR I can take a look at the extension of ``tm.assert_produces_warning`` to match messages.
I believe that extension of ``tm.assert_produces_warning`` goes beyond the scope of the present PR.
yep! sounds good! 

you could use use `tm.assert_produce_warning` in this PR and add a comment to refer to the original 13188, so later could easily catch them! Please also do it for `test_errorbar_plot` test as well!

> I believe that extension of tm.assert_produces_warning goes beyond the scope of the present PR.

yeah, a follow-up would be great!
Did that. But also I decided to move from ``test_errorbar_plot`` part related to various kinds in a separate parametrize test. Can revert it if this is not suitable. But to me it seems that in general it would be required to split some test functions into smaller ones with more relevant names.
> I decided to move from test_errorbar_plot part related to various kinds in a separate parametrize test

sure!
I checked.
Here is the output.

```
(base) root@f31dd4516194:/workspaces/pandas# pytest pandas/tests/plotting/test_frame.py
======================================================================================================================== test session starts =========================================================================================================================
platform linux -- Python 3.7.7, pytest-6.0.1, py-1.9.0, pluggy-0.13.1
rootdir: /workspaces/pandas, configfile: setup.cfg
plugins: cov-2.10.0, forked-1.2.0, xdist-1.34.0, hypothesis-5.23.11, asyncio-0.12.0
collected 191 items                                                                                                                                                                                                                                                  

pandas/tests/plotting/test_frame.py ...........................x....................................................................................................x..............................................................                            [100%]

========================================================================================================================== warnings summary ==========================================================================================================================
pandas/tests/plotting/test_frame.py::TestDataFramePlots::test_mpl2_color_cycle_str
  /workspaces/pandas/pandas/plotting/_matplotlib/style.py:64: MatplotlibDeprecationWarning: Support for uppercase single-letter colors is deprecated since Matplotlib 3.1 and will be removed in 3.3; please use lowercase instead.
    [conv.to_rgba(c) for c in colors]

-- Docs: https://docs.pytest.org/en/stable/warnings.html
======================================================================================================== 189 passed, 2 xfailed, 1 warning in 64.14s (0:01:04) ========================================================================================================
(base) root@f31dd4516194:/workspaces/pandas#
```

Another warning is handled in https://github.com/pandas-dev/pandas/pull/36981
thanks @ivanovmg