Given this 3D bar graph sample code, how would you convert the numerical data in the x-axis to formatted date/time strings? I ve attempted using the ax.xaxis_date() function without success. I also tried using plot_date(), which doesn t appear to work for 3D bar graphs. Here is a modified version of the sample code to illustrate what I am trying to do:
from mpl_toolkits.mplot3d import Axes3D
import matplotlib.pyplot as plt
import numpy as np
import matplotlib.dates as dates
dates = [dates.date2num(datetime.datetime(2009,3,12)),
dates.date2num(datetime.datetime(2009,6,9)),
dates.date2num(datetime.datetime(2010,1,1)),
#etc...
]
fig = plt.figure()
ax = Axes3D(fig)
for c, z in zip([ r , g , b , y ], [30, 20, 10, 0]):
xs = np.array(dates)
ys = np.random.rand(20)
ax.bar(xs, ys, zs=z, zdir= y , color=c, alpha=0.8)
ax.set_xlabel( Date & Time )
ax.set_ylabel( Series )
ax.set_zlabel( Amount )
plt.show()