Skip to content

Commit 4611140

Browse files
committed
BUG: Fix the un-pickleable plot with DatetimeIndex
1 parent be66ef8 commit 4611140

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

pandas/plotting/_timeseries.py

+7-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# TODO: Use the fact that axis can have units to simplify the process
22

3+
import functools
4+
35
import numpy as np
46

57
from matplotlib import pylab
@@ -293,6 +295,10 @@ def format_timedelta_ticks(x, pos, n_decimals):
293295
return s
294296

295297

298+
def _format_coord(freq, t, y):
299+
return "t = {0} y = {1:8f}".format(Period(ordinal=int(t), freq=freq), y)
300+
301+
296302
def format_dateaxis(subplot, freq, index):
297303
"""
298304
Pretty-formats the date axis (x-axis).
@@ -327,8 +333,7 @@ def format_dateaxis(subplot, freq, index):
327333
subplot.xaxis.set_minor_formatter(minformatter)
328334

329335
# x and y coord info
330-
subplot.format_coord = lambda t, y: (
331-
"t = {0} y = {1:8f}".format(Period(ordinal=int(t), freq=freq), y))
336+
subplot.format_coord = functools.partial(_format_coord, freq)
332337

333338
elif isinstance(index, TimedeltaIndex):
334339
subplot.xaxis.set_major_formatter(

0 commit comments

Comments
 (0)