Thursday, October 29, 2015

Sample Python Codes plot value with date time axis in matplotlib



[1] stackoverflow.com/ plotting-time-in-python-with-matplotlib



#!/usr/bin/env python

import matplotlib.pyplot as plt
import datetime



ax = tuple([datetime.datetime(2015, 10, 27, 17, 17, sec) for sec in range(1,10)])
print ax

ay = tuple(range(1,10))

plt.plot(ax,ay)
# Beautify the display format
plt.gcf().autofmt_xdate()
plt.show()


When doing enough zoom in, it will display in macro seconds resolution. When zooming out enough,it will display dates.

No comments: