DEPR: Fixed warning for implicit registration
State: closed

Reminder: We want people to explicitly call `pandas.plotting.register_matplotlib_converters()` when using a matplotlib plotting method with a pandas object. We implicitly call it as part of Series/Frame.plot.


```python
In [1]: import pandas as pd
In [2]: import matplotlib.pyplot as plt
In [3]: fig, ax = plt.subplots()
In [4]: s = pd.Series(range(12), index=pd.date_range('2017', periods=12))
In [5]: ax.plot(s)
## -- End pasted text --
Using matplotlib backend: TkAgg
/Users/taugspurger/sandbox/pandas/pandas/plotting/_converter.py:129: FutureWarning: Using an implicitly registered datetime converter for a matplotlib plotting method. The converter was registered by pandas on import. Future versions of pandas will require you to explicitly register matplotlib converters.

To register the converters:
        >>> from pandas.plotting import register_matplotlib_converters
        >>> register_matplotlib_converters()
  warnings.warn(msg, FutureWarning)
Out[1]: [<matplotlib.lines.Line2D at 0x1077d7b38>]
```

I'm not quite sure what happened in 
https://github.com/pandas-dev/pandas/pull/18307, but the warning wasn't showing up by default.

Closes https://github.com/pandas-dev/pandas/issues/24963

Labels:
name: Visualization
description: plotting

Comments:
# [Codecov](https://codecov.io/gh/pandas-dev/pandas/pull/24964?src=pr&el=h1) Report
> Merging [#24964](https://codecov.io/gh/pandas-dev/pandas/pull/24964?src=pr&el=desc) into [master](https://codecov.io/gh/pandas-dev/pandas/commit/2b16e2e6c5a298396727fc2e66a60edf1eb13bf9?src=pr&el=desc) will **not change** coverage.
> The diff coverage is `100%`.

[![Impacted file tree graph](https://codecov.io/gh/pandas-dev/pandas/pull/24964/graphs/tree.svg?width=650&token=eZ4WkYLtcO&height=150&src=pr)](https://codecov.io/gh/pandas-dev/pandas/pull/24964?src=pr&el=tree)

```diff
@@           Coverage Diff           @@
##           master   #24964   +/-   ##
=======================================
  Coverage   92.38%   92.38%           
=======================================
  Files         166      166           
  Lines       52398    52398           
=======================================
  Hits        48406    48406           
  Misses       3992     3992
```

| Flag | Coverage Δ | |
|---|---|---|
| #multiple | `90.8% <100%> (ø)` | :arrow_up: |
| #single | `42.89% <100%> (-0.01%)` | :arrow_down: |

| [Impacted Files](https://codecov.io/gh/pandas-dev/pandas/pull/24964?src=pr&el=tree) | Coverage Δ | |
|---|---|---|
| [pandas/plotting/\_core.py](https://codecov.io/gh/pandas-dev/pandas/pull/24964/diff?src=pr&el=tree#diff-cGFuZGFzL3Bsb3R0aW5nL19jb3JlLnB5) | `83.58% <100%> (ø)` | :arrow_up: |

------

[Continue to review full report at Codecov](https://codecov.io/gh/pandas-dev/pandas/pull/24964?src=pr&el=continue).
> **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta)
> `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
> Powered by [Codecov](https://codecov.io/gh/pandas-dev/pandas/pull/24964?src=pr&el=footer). Last update [2b16e2e...8a84ea5](https://codecov.io/gh/pandas-dev/pandas/pull/24964?src=pr&el=lastupdated). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments).

# [Codecov](https://codecov.io/gh/pandas-dev/pandas/pull/24964?src=pr&el=h1) Report
> Merging [#24964](https://codecov.io/gh/pandas-dev/pandas/pull/24964?src=pr&el=desc) into [master](https://codecov.io/gh/pandas-dev/pandas/commit/bf693ffb520da3b315737a8d52595646afa74d63?src=pr&el=desc) will **decrease** coverage by `<.01%`.
> The diff coverage is `100%`.

[![Impacted file tree graph](https://codecov.io/gh/pandas-dev/pandas/pull/24964/graphs/tree.svg?width=650&token=eZ4WkYLtcO&height=150&src=pr)](https://codecov.io/gh/pandas-dev/pandas/pull/24964?src=pr&el=tree)

```diff
@@            Coverage Diff             @@
##           master   #24964      +/-   ##
==========================================
- Coverage   92.38%   92.38%   -0.01%     
==========================================
  Files         166      166              
  Lines       52400    52400              
==========================================
- Hits        48409    48408       -1     
- Misses       3991     3992       +1
```

| Flag | Coverage Δ | |
|---|---|---|
| #multiple | `90.8% <100%> (ø)` | :arrow_up: |
| #single | `42.89% <100%> (ø)` | :arrow_up: |

| [Impacted Files](https://codecov.io/gh/pandas-dev/pandas/pull/24964?src=pr&el=tree) | Coverage Δ | |
|---|---|---|
| [pandas/plotting/\_core.py](https://codecov.io/gh/pandas-dev/pandas/pull/24964/diff?src=pr&el=tree#diff-cGFuZGFzL3Bsb3R0aW5nL19jb3JlLnB5) | `83.58% <100%> (ø)` | :arrow_up: |
| [pandas/util/testing.py](https://codecov.io/gh/pandas-dev/pandas/pull/24964/diff?src=pr&el=tree#diff-cGFuZGFzL3V0aWwvdGVzdGluZy5weQ==) | `88.04% <0%> (-0.1%)` | :arrow_down: |

------

[Continue to review full report at Codecov](https://codecov.io/gh/pandas-dev/pandas/pull/24964?src=pr&el=continue).
> **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta)
> `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
> Powered by [Codecov](https://codecov.io/gh/pandas-dev/pandas/pull/24964?src=pr&el=footer). Last update [bf693ff...f791e3d](https://codecov.io/gh/pandas-dev/pandas/pull/24964?src=pr&el=lastupdated). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments).

I'm open to suggestions. But what about this is technical debt to you, that will slow down future development?
> I'm open to suggestions. But what about this is technical debt to you, that will slow down future development?

 you are adding a completely different framework in a special place. This is not great. I am most concerned about the separate call in the CI files.
K. Let me know if you have suggestions for how to avoid that.

On Mon, Jan 28, 2019 at 7:35 AM Jeff Reback <notifications@github.com>
wrote:

> I'm open to suggestions. But what about this is technical debt to you,
> that will slow down future development?
>
> you are adding a completely different framework in a special place. This
> is not great. I am most concerned about the separate call in the CI files.
>
> —
> You are receiving this because you authored the thread.
> Reply to this email directly, view it on GitHub
> <https://github.com/pandas-dev/pandas/pull/24964#issuecomment-458134303>,
> or mute the thread
> <https://github.com/notifications/unsubscribe-auth/ABQHIlNLvwE7nuL7_KB-_K-d04JdaANtks5vHvyygaJpZM4aU805>
> .
>

> K. Let me know if you have suggestions for how to avoid that

If you can't find a way with pytest, then I would simply remove the entire test.
The only other thing I can think of is passing running the test in a subprocess, but trying to capture the stderr from that seems worse than using a test framework.
> If you can't find a way with pytest, then I would simply remove the entire test.

I have a slight preference to testing this.
> I have a slight preference to testing this.

I agree. But the way it is tested now is not great. 
Removed the tests.
thanks @TomAugspurger 
I can confirm it is now warning on master!
Hi everyone. Thanks for the amazing pandas package.

I get this warning even when I'm not plotting any pandas objects. When I remove the pandas import the warning disappears and the plotting works as expected. Is this expected behaviour?
It *sounds* like that is indeed the expected warning, but it will be easier to judge if you can show a reproducible code example.

Pandas currently automatically registers some custom unit converters with matplotlib, which are used even when you don't use pandas' plotting methods. So that's what the warning is for, if something is not clear from the warning message, feedback very welcome!
OK great! I explicitly registered the converters now.

Code example:

```python
import pandas as pd
import matplotlib.pyplot as plt
from datetime import datetime

plt.plot([datetime(2012,1,1), datetime(2012,1,2)], [1,2])
plt.show()
```

@cfjhallgren pandas overwrites some of Matplotlib's units

```python
In [3]: matplotlib.units.registry
Out[3]:
{str: <matplotlib.category.StrCategoryConverter at 0x10e931358>,
 numpy.str_: <matplotlib.category.StrCategoryConverter at 0x10e931390>,
 bytes: <matplotlib.category.StrCategoryConverter at 0x10e9313c8>,
 numpy.bytes_: <matplotlib.category.StrCategoryConverter at 0x10e931400>,
 numpy.datetime64: <matplotlib.dates.DateConverter at 0x10e9711d0>,
 datetime.date: <matplotlib.dates.DateConverter at 0x10e971208>,
 datetime.datetime: <matplotlib.dates.DateConverter at 0x10e971240>}

In [4]: import pandas

In [5]: matplotlib.units.registry
Out[5]:
{str: <matplotlib.category.StrCategoryConverter at 0x10e931358>,
 numpy.str_: <matplotlib.category.StrCategoryConverter at 0x10e931390>,
 bytes: <matplotlib.category.StrCategoryConverter at 0x10e9313c8>,
 numpy.bytes_: <matplotlib.category.StrCategoryConverter at 0x10e931400>,
 numpy.datetime64: <pandas.plotting._converter.DatetimeConverter at 0x1119400b8>,
 datetime.date: <pandas.plotting._converter.DatetimeConverter at 0x111925dd8>,
 datetime.datetime: <pandas.plotting._converter.DatetimeConverter at 0x1119255c0>,
 pandas._libs.tslibs.timestamps.Timestamp: <pandas.plotting._converter.DatetimeConverter at 0x1119252e8>,
 pandas._libs.tslibs.period.Period: <pandas.plotting._converter.PeriodConverter at 0x111925550>,
 datetime.time: <pandas.plotting._converter.TimeConverter at 0x111940080>}
````

so you were getting pandas' formatting of those datetime objects.
Interesting, thanks!