Hello,
I am trying to make a simple pcolor plot with a datetime on the x-axis. I
am able to get a time label on the x-axis fine with a regular plot command,
but it doesn't appear to work if you use pcolor. This simple example below
shows that it does not work. Does anyone have any idea as to why a
datetime can't go on a pcolor plot? What is the best approach is to solve
the problem?
Thanks,
Tim
import numpy as np
import datetime
import random
import matplotlib
import matplotlib.pyplot as plt
# create some random data, one for a line plot, and another for pcolor:
data1 = np.array ([random.random() for k in range(10)])
data2 = np.zeros((10,10))
for i in range(10):
for j in range(10):
data2[i,j] = random.random()
# build datetimes (dts):
dts = []
for k in range(10):
dts.append(datetime.datetime(2012,1,1+k))
# First example, showing a regular plot with datetimes in the x-axis.
fig = plt.figure(1)
fig.clf()
ax = fig.add_subplot(111)
ax.plot(dts,data1)
plt.show()
# Second example, showing a pcolor with datetimes in the x-axis.
# This plot does not work.
fig = plt.figure(2)
fig.clf()
ax = fig.add_subplot(111)
ax.pcolor(dts,np.arange(10),data2)
plt.show()
------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and
threat landscape has changed and how IT managers can respond. Discussions
will include endpoint security, mobile security and the latest in malware
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users