Description
Code Sample, a copy-pastable example if possible
%matplotlib inline
import pandas
import datetime as pydt
pandas.DataFrame({'A': 1}, index=[pydt.time(1, 1, 1, 1), pydt.time(1, 1, 1, 100)]).plot()
Problem description
The TimeFormatter code has several issues. The first is here:
pandas/pandas/plotting/_converter.py
Line 113 in 4fce784
ms
needs to be multiplied by 1e3, otherwise we'd be subtracting milliseconds from microseconds.
The next problem is here:
pandas/pandas/plotting/_converter.py
Line 118 in 4fce784
The strftime format does not support the %6f
notation. This needs to be %f
, otherwise the result would be either a literal '%6f' in the output or a ValueError (invalid format string).
pandas/pandas/plotting/_converter.py
Line 120 in 4fce784
Same problems, plus: '%f' means microseconds for strftime(), %3f
cannot turn this into milliseconds.
And the last one:
pandas/pandas/plotting/_converter.py
Line 122 in 4fce784
This timestamp is missing the milliseconds entirely. (Assuming the fix to the microsecond calculation mentioned above.)
Expected Output
Correctly formatted time stamp strings as tick labels.
Solution Approaches
- Drop the TimeFormatter entirely (after checking if MPL already copes with pydt.time())
- Drop any sub-second resolution support from the TimeFormatter, as it was broken for a long time and nobody complained.
- Make it work correctly in the way it was most likely intended to work.
What do you think? I can set up a pull request for option 3 if that's the preferred solution.