Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]: ConciseDateFormatter not showing offset #21670

Closed
Stassels opened this issue Nov 18, 2021 · 4 comments · Fixed by #21785
Closed

[Bug]: ConciseDateFormatter not showing offset #21670

Stassels opened this issue Nov 18, 2021 · 4 comments · Fixed by #21785

Comments

@Stassels
Copy link

Stassels commented Nov 18, 2021

Bug summary

When I create time series plot with too big time range, I can't see offset in lower right corner.

Code for reproduction

import numpy as np
import pandas as pd
import matplotlib.pyplot as plt

LEN = 40000
dt_index = pd.date_range('2013-01-01 00:00', periods=LEN, freq='5min')
df = pd.DataFrame({'data': np.random.randint(10, size=LEN)},index=dt_index)

fig, ax = plt.subplots()
import matplotlib.dates as mdates

locator = mdates.AutoDateLocator()
formatter = mdates.ConciseDateFormatter(locator)
ax.xaxis.set_major_locator(locator)
ax.xaxis.set_major_formatter(formatter)

ax.plot(df.index, df.data)

plt.show()

Actual outcome

image

Expected outcome

image

Additional information

When changing time range with fewer points, I can see the offset as seen in expected outcome.

Operating system

Ubuntu

Matplotlib Version

3.4.3

Matplotlib Backend

Qt5Agg

Python version

3.9

Jupyter version

No response

Installation

No response

@jklymak
Copy link
Member

jklymak commented Nov 18, 2021

There is no offset if the year is indicated in the axis somewhere. I think this is expected behaviour.

@Stassels
Copy link
Author

There is no offset if the year is indicated in the axis somewhere. I think this is expected behaviour.

Sorry, I probably didn't wrote it clearly enough.
When I use pan/zoom tool and zoom in to months/days/day, I still can't see the offset. I think that's not expected behavior.

But when I use this example and change LEN to 35000 and then use pan/zoom tool and zoom out, I can see the offset in any zoom level.

@dstansby
Copy link
Member

Thanks for the self contained example; I can reproduce this bug.

@jklymak
Copy link
Member

jklymak commented Nov 28, 2021

Thanks both! #21785 should fix this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants