File tree 3 files changed +22
-3
lines changed
3 files changed +22
-3
lines changed Original file line number Diff line number Diff line change @@ -112,6 +112,9 @@ Plotting
112
112
^^^^^^^^
113
113
114
114
- Added a pandas_plotting_backends entrypoint group for registering plot backends. See :ref: `extending.plotting-backends ` for more (:issue: `26747 `).
115
+ - Fixed the re-instatement of Matplotlib datetime converters after calling
116
+ `pandas.plotting.deregister_matplotlib_converters() ` (:issue: `27481 `).
117
+ -
115
118
- Fix compatibility issue with matplotlib when passing a pandas ``Index `` to a plot call (:issue: `27775 `).
116
119
-
117
120
Original file line number Diff line number Diff line change @@ -64,11 +64,12 @@ def register(explicit=True):
64
64
65
65
pairs = get_pairs ()
66
66
for type_ , cls in pairs :
67
- converter = cls ()
68
- if type_ in units .registry :
67
+ # Cache previous converter if present
68
+ if type_ in units .registry and not isinstance ( units . registry [ type_ ], cls ) :
69
69
previous = units .registry [type_ ]
70
70
_mpl_units [type_ ] = previous
71
- units .registry [type_ ] = converter
71
+ # Replace with pandas converter
72
+ units .registry [type_ ] = cls ()
72
73
73
74
74
75
def deregister ():
Original file line number Diff line number Diff line change @@ -40,6 +40,21 @@ def test_initial_warning():
40
40
assert "Using an implicitly" in out
41
41
42
42
43
+ def test_registry_mpl_resets ():
44
+ # Check that Matplotlib converters are properly reset (see issue #27481)
45
+ code = (
46
+ "import matplotlib.units as units; "
47
+ "import matplotlib.dates as mdates; "
48
+ "n_conv = len(units.registry); "
49
+ "import pandas as pd; "
50
+ "pd.plotting.register_matplotlib_converters(); "
51
+ "pd.plotting.deregister_matplotlib_converters(); "
52
+ "assert len(units.registry) == n_conv"
53
+ )
54
+ call = [sys .executable , "-c" , code ]
55
+ subprocess .check_output (call )
56
+
57
+
43
58
def test_timtetonum_accepts_unicode ():
44
59
assert converter .time2num ("00:01" ) == converter .time2num ("00:01" )
45
60
You can’t perform that action at this time.
0 commit comments