jakevdp/mpld3 — pull request #11 by jkfurtney (2013-12-21 21:59:33+00:00)
Title: Time scale support for x axis

Hi, Thanks again for providing this, it is coming together nicely.

This adds support for date ranges on the x axis. d3.time.scale() is used to create the scale and it automatically formats the dates as you zoom. I was unsure about a few things: how do you tell if a matplotlib axis is a time scale? I currently check the type of ax.xaxis.converter, which seems to work.

I had to introduce an extra javascript function to map from the matplotlib floating point date format to a javascript date object and again to the width of the figure. There must be a better way to do this? Maybe transform the actual data array in the javascript part?

For future reference, if you are creating javascript date objects with the Date() constructor: the month is specified as an integer from 0 to 11. This caused me some confusion.

Here my test case.
```python
import numpy as np
import pylab as plt
import matplotlib
import datetime
import time
from mpld3.display import display_d3

otimes = map(datetime.datetime.fromtimestamp, [time.time()+i*500
for i in range(10)])
times = matplotlib.dates.date2num(otimes)

plt.gca().xaxis_date()
plt.gcf().autofmt_xdate()

plt.plot_date(times, range(10), "-",linewidth=3)

print plt.gca().get_xlim()

#plt.show()
display_d3(plt.gcf())
```