pyecharts各种图表实现(超级全)(上)

简介: 以下默认都是在Jupyter Notebook展示 也可以将每个图代码的最后一行换为 所创建的对象.render('名字.html')转换为html文件就可以查看啦

平面直角坐标系

直方图

x_data = ['Apple', 'Huawei', 'Xiaomi', 'Oppo', 'Vivo', 'Meizu']
y_data = [123, 153, 89, 107, 98, 23]
bar = (Bar()
       .add_xaxis(x_data)
       .add_yaxis('', y_data)
      )
bar.render_notebook()

2345_image_file_copy_31.jpg

折线图

x_data = ['Apple', 'Huawei', 'Xiaomi', 'Oppo', 'Vivo', 'Meizu']
y_data = [123, 153, 89, 107, 98, 23]
line = (Line()
       .add_xaxis(x_data)
       .add_yaxis('', y_data)
      )
line.render_notebook()

2345_image_file_copy_32.jpg

箱形图

x_data = ['Apple', 'Huawei', 'Xiaomi', 'Oppo', 'Vivo', 'Meizu']
y_data = [[random.randint(100, 200) for i in range(10)] for item in x_data]
Box = Boxplot()
Box.add_xaxis(x_data)
Box.add_yaxis("", Box.prepare_data(y_data))
Box.render_notebook()

2345_image_file_copy_33.jpg

散点图

x_data = ['Apple', 'Huawei', 'Xiaomi', 'Oppo', 'Vivo', 'Meizu']
y_data = [123, 153, 89, 107, 98, 23]
scatter = (Scatter()
           .add_xaxis(x_data)
           .add_yaxis('', y_data)
           )
scatter.render_notebook()

2345_image_file_copy_34.jpg

带涟漪效果散点图

x_data = ['Apple', 'Huawei', 'Xiaomi', 'Oppo', 'Vivo', 'Meizu']
y_data = [123, 153, 89, 107, 98, 23]
effectScatter = (EffectScatter()
           .add_xaxis(x_data)
           .add_yaxis('', y_data)
           )
effectScatter.render_notebook()

2345_image_file_copy_35.jpg

k线图

date_list = ["2020/4/{}".format(i + 1) for i in range(30)]
y_data = [
    [2320.26, 2320.26, 2287.3, 2362.94],
    [2300, 2291.3, 2288.26, 2308.38],
    [2295.35, 2346.5, 2295.35, 2345.92],
    [2347.22, 2358.98, 2337.35, 2363.8],
    [2360.75, 2382.48, 2347.89, 2383.76],
    [2383.43, 2385.42, 2371.23, 2391.82],
    [2377.41, 2419.02, 2369.57, 2421.15],
    [2425.92, 2428.15, 2417.58, 2440.38],
    [2411, 2433.13, 2403.3, 2437.42],
    [2432.68, 2334.48, 2427.7, 2441.73],
    [2430.69, 2418.53, 2394.22, 2433.89],
    [2416.62, 2432.4, 2414.4, 2443.03],
    [2441.91, 2421.56, 2418.43, 2444.8],
    [2420.26, 2382.91, 2373.53, 2427.07],
    [2383.49, 2397.18, 2370.61, 2397.94],
    [2378.82, 2325.95, 2309.17, 2378.82],
    [2322.94, 2314.16, 2308.76, 2330.88],
    [2320.62, 2325.82, 2315.01, 2338.78],
    [2313.74, 2293.34, 2289.89, 2340.71],
    [2297.77, 2313.22, 2292.03, 2324.63],
    [2322.32, 2365.59, 2308.92, 2366.16],
    [2364.54, 2359.51, 2330.86, 2369.65],
    [2332.08, 2273.4, 2259.25, 2333.54],
    [2274.81, 2326.31, 2270.1, 2328.14],
    [2333.61, 2347.18, 2321.6, 2351.44],
    [2340.44, 2324.29, 2304.27, 2352.02],
    [2326.42, 2318.61, 2314.59, 2333.67],
    [2314.68, 2310.59, 2296.58, 2320.96],
    [2309.16, 2286.6, 2264.83, 2333.29],
    [2282.17, 2263.97, 2253.25, 2286.33],
]
kline = (Kline()
         .add_xaxis(date_list)
         .add_yaxis('', y_data)
         )
kline.render_notebook()

2345_image_file_copy_36.jpg

热力图

data = [[i, j, random.randint(0, 100)] for i in range(24) for j in range(7)]
hour_list = [str(i) for i in range(24)]
week_list = ['周日', '周一', '周二', '周三', '周四', '周五', '周六']
heat = (HeatMap()
        .add_xaxis(hour_list)
        .add_yaxis("", week_list, data)
        )
heat.render_notebook()

2345_image_file_copy_37.jpg

象型图

x_data = ['Apple', 'Huawei', 'Xiaomi', 'Oppo', 'Vivo', 'Meizu']
y_data = [123, 153, 89, 107, 98, 23]
pictorialBar = (PictorialBar()
                .add_xaxis(x_data)
                .add_yaxis('', y_data)
                )
pictorialBar.render_notebook()

2345_image_file_copy_38.jpg

层叠图

x_data = ['Apple', 'Huawei', 'Xiaomi', 'Oppo', 'Vivo', 'Meizu']
y_data_bar = [123, 153, 89, 107, 98, 23]
y_data_line = [153, 107, 23, 89, 123, 107]
bar = (Bar()
       .add_xaxis(x_data)
       .add_yaxis('', y_data_bar)
       )
line = (Line()
        .add_xaxis(x_data)
        .add_yaxis('', y_data_line)
        )
overlap = bar.overlap(line)
overlap.render_notebook()

2345_image_file_copy_39.jpg

地理图表

GEO-地理坐标系

province = [
    '广东',
    '湖北',
    '湖南',
    '四川',
    '重庆',
    '黑龙江',
    '浙江',
    '山西',
    '河北',
    '安徽',
    '河南',
    '山东',
    '西藏']
data = [(i, random.randint(50, 150)) for i in province]
geo = (
    Geo()
    .add_schema(maptype="china")
    .add("", data)
)
geo.render_notebook()


MAP-地图

province = [
    '广东',
    '湖北',
    '湖南',
    '四川',
    '重庆',
    '黑龙江',
    '浙江',
    '山西',
    '河北',
    '安徽',
    '河南',
    '山东',
    '西藏']
data = [(i, random.randint(50, 150)) for i in province]
map_ = (
    Map()
    .add("", data, 'china')
)
map_.render_notebook()


BMAP-百度地图

province = [
    '广东',
    '湖北',
    '湖南',
    '四川',
    '重庆',
    '黑龙江',
    '浙江',
    '山西',
    '河北',
    '安徽',
    '河南',
    '山东',
    '西藏']
data = [(i, random.randint(50, 150)) for i in province]
bmap = (
    BMap()
    .add_schema(baidu_ak="FAKE_AK", center=[120.13066322374, 30.240018034923])
    .add("", data)
)
bmap.render_notebook()

基本图表

饼图

# 虚假数据
cate = ['Apple', 'Huawei', 'Xiaomi', 'Oppo', 'Vivo', 'Meizu']
data = [123, 153, 89, 107, 98, 23]
pie = (Pie()
       .add('', [list(z) for z in zip(cate, data)])
       )
pie.render_notebook()

2345_image_file_copy_42.jpg

漏斗图

# 虚假数据
cate = ['访问', '注册', '加入购物车', '提交订单', '付款成功']
data = [30398, 15230, 10045, 3109, 1698]
funnel = (Funnel()
          .add("", [list(z) for z in zip(cate, data)])
          )
funnel.render_notebook()

2345_image_file_copy_43.jpg

仪表盘

gauge = (Gauge()
          .add("", [('转化率',34)])
          )
gauge.render_notebook()

2345_image_file_copy_44.jpg

水球图

liquid = (Liquid()
          .add("", [0.52, 0.44])
          )
liquid.render_notebook()

2345_image_file_copy_45.jpg

日历图

import math
# 虚假数据
begin = datetime.date(2019, 1, 1)
end = datetime.date(2019, 12, 31)
data = [[str(begin + datetime.timedelta(days=i)), abs(math.cos(i/100))* random.randint(1000, 1200)]
        for i in range((end - begin).days + 1)]
calendar = (
        Calendar()
        .add("", data, calendar_opts=opts.CalendarOpts(range_="2019"))
    )
calendar.render_notebook()

2345_image_file_copy_46.jpg

目录
相关文章
|
12月前
|
数据可视化 Python
【100天精通Python】Day62:Python可视化_Matplotlib绘图基础,绘制折线图、散点图、柱状图、直方图和饼图,以及自定义图标外观和功能,示例+代码
【100天精通Python】Day62:Python可视化_Matplotlib绘图基础,绘制折线图、散点图、柱状图、直方图和饼图,以及自定义图标外观和功能,示例+代码
187 0
|
2月前
|
数据可视化 Python
Matplotlib基本图表的完全指南
【8月更文挑战第21天】Matplotlib 是一款强大的 Python 图表库,适用于数据科学家、工程师及研究人员,帮助直观地探索与展示数据。本文全面介绍了 Matplotlib 的使用方法:从安装到导入库,再到创建基础图表如折线图、散点图、柱状图及饼图。此外还探讨了图表样式的自定义、子图的使用、图表保存以及利用数据集绘图的方法。文章进一步展示了如何绘制多系列数据、应用样式表,并提供了三维图等高级功能的示例。通过这些指南,读者能够掌握 Matplotlib 的基本与进阶用法,从而有效地可视化复杂数据。
44 6
|
2月前
|
数据可视化 Python
五种Pandas图表美化样式汇总
五种Pandas图表美化样式汇总
|
2月前
|
数据可视化 Python
Pandas可视化指南:从零教你绘制数据图表
Pandas可视化指南:从零教你绘制数据图表
|
5月前
|
数据可视化 Python
使用pyecharts库绘制柱状图:基础与进阶
使用pyecharts库绘制柱状图:基础与进阶
125 0
|
11月前
Echarts柱状图折线图混合使用
Echarts柱状图折线图混合使用
114 0
|
12月前
|
JSON 数据可视化 数据格式
pyecharts可视化
pyecharts画图包是python里非常好用的可视化包。其也可以通过json配置画图组合,做一个可视化大屏界面。最后可以制作如下可视化图表,掌握其制作方法其他更多组合可以自行配置。
68 0
|
数据可视化
可视化 | Pyecharts 单轴散点图(附完整代码)
可视化 | Pyecharts 单轴散点图(附完整代码)
|
数据可视化 Python 容器
基础 | Pyecharts绘图基础之图例配置项(LegendOpts)
基础 | Pyecharts绘图基础之图例配置项(LegendOpts)
|
开发者
pyecharts基础之柱状图的绘制
pyecharts分为v0.5.X和v1两个大版本,0.5.x 版本将不再进行维护推荐使用v1版本
102 0