准备 代码 # coding=utf-8 # 代码文件:code/chapter10/10.3.py # 3D柱状图import randomfrom pyecharts import options as opts from pyecharts.charts import Bar3D# 生成测试数据 data = [[x, y, random.randint(10, 40)] for y in range(7) for x in range(24)]hours = ['12a', '1a', '2a', '3a', '4a', '5a', '6a', '7a', '8a', '9a', '10a', '11a', '12p', '1p', '2p', '3p', '4p', '5p','6p', '7p', '8p', '9p', '10p', '11p', ] weeks = ['星期六', '星期五', '星期四', '星期三', '星期二', '星期一', '星期日']c = (Bar3D(init_opts=opts.InitOpts(width='1200px', height='600px')).add('',data,xaxis3d_opts=opts.Axis3DOpts(name='小时', data=hours),yaxis3d_opts=opts.Axis3DOpts(name='星期', data=weeks),zaxis3d_opts=opts.Axis3DOpts(name='温度'),).set_global_opts(visualmap_opts=opts.VisualMapOpts(max_=50, min_=0),title_opts=opts.TitleOpts(title='Q市7×24小时温度'),).render('data/3D柱状图.html')) 效果