Matplotlib 3d条形图:错误:无法连接'str'和'float'对象

时间:2014-05-09 08:48:46

标签: python numpy matplotlib pandas

我的代码出错:"错误:无法连接' str'并且'漂浮'对象&#34 ;.任何的想法? 感谢您的帮助!

from mpl_toolkits.mplot3d import Axes3D
import matplotlib.pyplot as plt
import numpy as np
from pandas import *
import matplotlib.ticker as ticker

fig=plt.figure()
ax=fig.add_subplot(111,projection='3d')

df1= read_csv("/user_home/w_andalib_dvpy/sample_data/3d_sample.csv")

xpos=df1['Date']
ypos=df1['Type']
zpos=df1['Duration']

for z in xpos :
    xs = xpos
    ys = ypos
    color = plt.cm.Set2(random.choice(xrange(plt.cm.Set2.N)))
    ax.bar(xs, ys, zs=z, zdir='y', color=color, alpha=0.8)

ax.xaxis.set_major_locator(mpl.ticker.FixedLocator(xs))
ax.yaxis.set_major_locator(mpl.ticker.FixedLocator(ys))    

ax.set_xlabel('Type')
ax.set_ylabel('Date')
ax.set_zlabel('Sum of Duration')

plt.show()

0 个答案:

没有答案