On Wed, Nov 9, 2011 at 11:45 PM, Gökhan Sever <gokhanse...@gmail.com> 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
------------------------------------------------------------------------------
RSA(R) Conference 2012
Save $700 by Nov 18
Register now
http://p.sf.net/sfu/rsa-sfdev2dev1
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users

Reply via email to