Python中进行3d条形绘制期间发生类型错误

时间:2018-10-16 02:09:29

标签: python matplotlib

我是python的新手,正在尝试绘制3D条形图。

但是,我一直遇到类型错误的问题。

基本上,我想在同一张图上绘制日期,调整后的收盘价和交易量。

此处的数据:

日期,打开,高,低,关闭,调整关闭,成交量

2018-09-05,110.580002,110.820000,109.699997,109.870003,109.870003,6388300

2018-09-06,110.000000,110.410004,109.360001,110.260002,110.260002,5267200

2018-09-07,110.080002,111.349998,110.010002,110.970001,110.970001,4754800

2018-09-10,111.440002,111.910004,110.370003,110.680000,110.680000,4636500

有人可以帮我吗?

此处的代码:

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

from matplotlib import style
import matplotlib.dates as dates  
import datetime, random
import matplotlib.ticker as ticker

def random_date():  
      date = datetime.date(2008, 12, 1)  
      while 1:
           date += datetime.timedelta(days=30)
           yield (date)

fig = plt.figure()
ax = Axes3D(fig,rect=[0,0.1,1,1]) 

ax.bar(date_list, ad_close, zs=vol, zdir = 'y', width = 8 )

ax.w_xaxis.set_major_locator(ticker.FixedLocator(date)) # I want all the dates on my xaxis
ax.w_xaxis.set_major_formatter(ticker.FuncFormatter(format_date))


for tl in ax.w_xaxis.get_ticklabels(): #re-create what autofmt_xdate but with w_xaxis

       tl.set_ha('right')

       tl.set_rotation(30)  


ax.set_ylabel('Adj Close')
ax.set_zlabel('Volume')

plt.show()

0 个答案:

没有答案