Skip to content

ConciseFormatter doesn't always label start of year properly #17958

@jklymak

Description

@jklymak

The January in this plot doesn't get labeled as 2021 in this plot:

using AutoDateLocator(minticks=20, maxticks=30) you get
image

There are no zeroes helping at the year mark here (actually the zero are month because of the wrong level), which makes >for a pretty fun read of this plot.
People wonder: is it 2020-2021 or 2021-2022 ? Why is there Jun in the bottom right?

Originally posted by @leolchat in #17269 (comment)

import matplotlib.pyplot as plt
import numpy as np
plt.rcParams['date.converter'] = 'concise'
import matplotlib.dates as mdates

locator = mdates.AutoDateLocator(minticks=20, maxticks=30)

dates = [np.datetime64( '2020-06-06 18:08:30'),  np.datetime64('2021-06-06 18:08:31')]

fig, ax = plt.subplots()
ax.plot(dates, [0, 1])
ax.set_xlim(np.datetime64( '2020-06-06 18:08:30.3'), np.datetime64( '2021-06-06 18:08:30.5'))
ax.xaxis.set_major_locator(locator)
plt.show()

Metadata

Metadata

Assignees

No one assigned

    Labels

    status: closed as inactiveIssues closed by the "Stale" Github Action. Please comment on any you think should still be open.status: inactiveMarked by the “Stale” Github Actiontopic: date handling

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions