Plotting date as hh:mm in contourf from seconds

Hi all,

I'm trying to make a contourf plot out of 3 2d fields, where one is seconds since 1970. This works! But my problem is the formatting of the xaxes. These I like to have in hh:mm. Since the time is a 2d field, a conversion to datetime didn't work.

The other way I tried was plotting a second axis with x as 1d datetime, y (1d) and z as before, removing the collections, plotting the original data and deleting the xticks and labels. But i didn't succeed with that. i get a year out of range error. Any help would be appreciated.

here is a small code peace that could help to understand what i like to do.

from matplotlib import pyplot, dates
import numpy as np

x = np.array([[1387029209.,1387029310.,1387029411.,1387029512.],
y = np.array([[143., 143., 133., 143.],
        [172., 162., 122., 172.],
        [201., 241., 201., 201.]])

z = np.random.rand(3,4)
fig = pyplot.figure()

dnt = dates.num2date(dates.epoch2num(x[0]))

ax2 = fig.add_axes([0.1,0.1,0.8,0.8])

c = ax2.contour(dnt,y[:,0],z)
for coll in c.collections:
time_format = dates.DateFormatter('%H:%M')

ax1 = fig.add_axes([0.1,0.1,0.8,0.8])


Dr. Mario Mech

Institute for Geophysics and Meteorology
University of Cologne
Pohligstr.3 / Room 3.120
50969 Cologne

t: +49(0)221-470-1776
f: +49(0)221-470-5198
e: mech@...2927...