|
From: Joe K. <jki...@wi...> - 2011-11-10 15:16:09
|
On Wed, Nov 9, 2011 at 11:45 PM, Gökhan Sever <gok...@gm...> wrote: > Hello, > > Is there any easy way to specify a time-axis using imshow to plot 2D data? > > Sure, just call "ax.xaxis_date()" (or "yaxis_date", depending on which axis you want to represent a date). As a quick example: import matplotlib.pyplot as plt import matplotlib.dates as mdates import numpy as np # Generate data... ny = 100 xmin, xmax = mdates.datestr2num(['01/01/2011', '11/10/2011']) data = np.random.random((ny, int(xmax-xmin)+1)) - 0.5 data = data.cumsum(axis=1) # Plot... fig, ax = plt.subplots() ax.imshow(data, extent=[xmin, xmax, 0, ny]) ax.xaxis_date() fig.autofmt_xdate() plt.show() Cheers, -Joe |