Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Bug : (minor) time axis labels show "%f" instead of microseconds for years up to 1900 #3179

Closed
@azjps

Description

@azjps

When plotting with a timestamp-based axis with datetimes of years <= 1900, upon zooming into sub-second scales, the default axis label date formatter shows "%f" instead of microseconds.

In [52]: import time, datetime, matplotlib.dates as mdates

In [53]: dt = mdates.date2num(datetime.datetime(1900, 1, 1, 10, 0))

In [54]: mdates.DateFormatter("%H:%M:%S.%f")(dt)
Out[54]: u'10:00:00.%f'

In [55]: time.strftime("%H:%M:%S.%f", (2000,) + mdates.num2date(dt).timetuple()[1:])
Out[55]: '10:00:00.%f'

This is since timetuple doesn't carry microsecond data. Minor in nature (was using a sentinel date of 1900 without realizing matplotlib would handle it specially) but I figured I would point it out.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions