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

Supported datetimes with microseconds, and those with long time series (>160 years). #1925

Merged
merged 4 commits into from May 20, 2013

Conversation

pelson
Copy link
Member

@pelson pelson commented Apr 19, 2013

This pull request updates the AutoDateLocator and AutoDateFormatter classes to handle extreme time series (<1 second and >160 years).

The follow code demonstrates the problems:



import datetime as dt
import numpy as np
import matplotlib.pyplot as plt


d1 = dt.datetime(1990, 1, 1)

if False:
    n = 365 * 200
    x = np.array([d1 + dt.timedelta(days=i) for i in range(n)], dtype=object)
else:
    n = int(1e4)
    x = np.array([d1 + dt.timedelta(microseconds=i * 10) for i in range(n)], dtype=object)

y = np.sin(np.linspace(0, np.pi * 2, n))

plt.figure(figsize=(12, 6))
plt.plot(x, y)

ax = plt.gca()
dt_loc = ax.xaxis.get_major_locator()
plt.show()

(try running this before this PR to see the improvement)


def __call__(self):
'Return the locations of the ticks'
self.refresh()
return self._locator()

def nonsingular(self, vmin, vmax):
# whatever is thrown at us, we can scale the unit.
# But default nonsigular date plots at an ~4 year period.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Small typo: nonsigular => nonsingular

@pelson
Copy link
Member Author

pelson commented Apr 25, 2013

Thanks @NelleV - I've added a commit which addresses your comments.

@NelleV
Copy link
Member

NelleV commented Apr 25, 2013

LGTM 👍 for merge !

@@ -573,6 +577,11 @@ def _get_interval(self):
return 1

def nonsingular(self, vmin, vmax):
"""
Given the proposed upper and lower extent, adjust the range
if it is too close to being singlular (i.e. a range of ~0).
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

typo: singular

@pelson
Copy link
Member Author

pelson commented May 14, 2013

Thanks @efiring - I've done all of the above. The dates module is also now completely pep8 compliant.
I've also removed the pdf and svg testing, which was not adding any value to the test suite (other than testing the svg and pdf backends which are being tested elsewhere).

I think this is good to go.

@mdboom
Copy link
Member

mdboom commented May 14, 2013

There are some Travis failures here, but once those are resolved, I think this looks good.

@pelson
Copy link
Member Author

pelson commented May 17, 2013

I've updated the failing test result (and removed the formats which are not exercising anything new).

@pelson
Copy link
Member Author

pelson commented May 20, 2013

Again, I think this is good for merge.

efiring added a commit that referenced this pull request May 20, 2013
Supported datetimes with microseconds, and those with long time series (>160 years).
@efiring efiring merged commit f30dc0a into matplotlib:master May 20, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants