Skip to content

STY: fix poor date-time format defaults #7815

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

Merged
merged 1 commit into from
Jan 13, 2017
Merged

Conversation

efiring
Copy link
Member

@efiring efiring commented Jan 13, 2017

Without this change, zooming in from ticks separated by
days to ticks separated by multiples of hours leaves tick
labels with no date information, even when the time period
covers several days.

With the change there is a systematic progression from one
level to the next, dropping the largest unit and adding a
smaller unit.

Without this change, zooming in from ticks separated by
days to ticks separated by multiples of hours leaves tick
labels with no date information, even when the time period
covers several days.

With the change there is a systematic progression from one
level to the next, dropping the largest unit and adding a
smaller unit.
@efiring efiring added this to the 2.0 (style change major release) milestone Jan 13, 2017
@efiring
Copy link
Member Author

efiring commented Jan 13, 2017

Consider something like a tidal height time series, simulated here:
tide_100days

Now zoom in to the first 3 days, with v2.x defaults, and notice that the x-ticks in the plot below are nearly useless:
tide_3days_orig

The following is the result of this PR:
tide_3days

Here is the example code, so you can try zooming in to smaller and smaller intervals, to see how bad the present defaults are.

import numpy as np
import matplotlib.pyplot as plt
import matplotlib.dates as mdates

x = mdates.datestr2num('2017-01-01') + np.linspace(0, 100, 5000)
y = np.sin(2 * np.pi * x * 24/12.42) + 0.5 * np.sin(2 * np.pi * x * 24/12)
fig, ax = plt.subplots()
ax.xaxis_date()
fig.autofmt_xdate()
ax.plot(x, y)
plt.show()

@tacaswell
Copy link
Member

I have also noted this, but never mustered the energy to do anything about it 👍

@NelleV NelleV merged commit e764e0f into matplotlib:v2.x Jan 13, 2017
@NelleV
Copy link
Member

NelleV commented Jan 13, 2017

Thanks @efiring

@efiring efiring deleted the date_labels branch January 13, 2017 07:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants