Created
March 12, 2016 02:32
-
-
Save dapangmao/07b8b25d669fd2a08ff4 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import matplotlib.pyplot as plt | |
import numpy as np | |
import matplotlib | |
import datetime | |
import time | |
import mpld3 | |
import matplotlib.pylab as pylab | |
pylab.rcParams['figure.figsize'] = 12, 5 # that's default image size for this interactive | |
def create_plot(): | |
otimes = [datetime.datetime(2015, k, j, i) for k in range(1, 13) for i in range(1, 11) for j in range(1, 28)] | |
times = matplotlib.dates.date2num(otimes) | |
np.random.seed(0) | |
fig, ax = plt.subplots() | |
ax.xaxis_date() | |
fig.autofmt_xdate() | |
ax.plot(times, np.random.random(len(times)), "o", alpha=0.3) | |
return fig | |
def test_date(): | |
fig = create_plot() | |
html = mpld3.fig_to_html(fig) | |
plt.close(fig) | |
mpld3.display(create_plot()) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment