多应用+插件架构,代码干净,二开方便,首家独创一键云编译技术,文档视频完善,免费商用码云13.8K 广告
[TOC] # 折线图 ~~~python from pyecharts.charts import Line from pyecharts.options import TitleOpts, LegendOpts, ToolboxOpts, VisualMapOpts # 构建折线图对象 line = Line() line.add_xaxis(["中国", '美国', "俄罗斯"]) # 填充X轴数据 line.add_yaxis("GDP", [30, 20, 25]) # 填充Y轴数据 # 设置全局配置 line.set_global_opts( title_opts=TitleOpts(title="GDP展示", pos_left="center", pos_bottom="1%"), # 标题,标题位置 legend_opts=LegendOpts(is_show=True), # 显示图例 toolbox_opts=ToolboxOpts(is_show=True), # 显示工具箱 visualmap_opts=VisualMapOpts(is_show=True) # 视觉映射 ) // 绘制折线图 line.render("折线图.html") ~~~ ![](https://img.kancloud.cn/cc/b3/ccb3b9c7cc748a374522fa7b764f60a9_905x513.png) # 数据可视化地图 ~~~python from pyecharts.charts import Map from pyecharts.options import VisualMapOpts map = Map() data = [ ("北京", 99), ("上海", 199), ("广东", 150), ("深圳", 120), ("山东", 6), ] name_map = {"北京市": "北京", "浙江省": "浙江", "天津市": "天津", "安徽省": "安徽", "上海市": "上海", "福建省": "福建", "重庆市": "重庆", "江西省": "江西", "香港特别行政区": "香港", "澳门特别行政区": "澳门", "山东省": "山东", "河南省": "河南", "内蒙古自治区": "内蒙古", "湖北省": "湖北", "新疆维吾尔自治区": "新疆", "湖南省": "湖南", "宁夏回族自治区": "宁夏", "广东省": "广东", "西藏自治区": "西藏", "海南省": "海南", "广西壮族自治区": "广西", "四川省": "四川", "河北省": "河北", "贵州省": "贵州", "山西省": "山西", "云南省": "云南", "辽宁省": "辽宁", "陕西省": "陕西", "吉林省": "吉林", "甘肃省": "甘肃", "黑龙江省": "黑龙江", "青海省": "青海", "江苏省": "江苏", "台湾省": "台湾"} map.add("测试地图", data, "china", name_map=name_map) # 标题,数据,国家,地区名称映射 map.set_global_opts( visualmap_opts=VisualMapOpts( is_show=True, is_piecewise=True, pieces=[ {"min": 1, "max": 9, "label": "1-9人", "color": "#CCFFFF"}, {"min": 10, "max": 99, "label": "10-99人", "color": "#FFFF99"}, {"min": 100, "max": 500, "label": "100-500人", "color": "#FF6666"} ] ) ) map.render("地图.html") ~~~ ![](https://img.kancloud.cn/b7/49/b74972e7ad5a5c4ab02a9598a57f9ce8_687x516.png) # 时间线-柱状图 ~~~python from peycharts.charts import Bar from pyecharts.options import LabelOpts from pyecharts.globals import ThemeType bar1 = Bar() bar1.add_xaxis(["中国", "美国", "俄罗斯"]) bar1.add_yaxis("GDP", [10, 20, 18], label_opts=LabelOpts(position="right")) # 数值靠右 bar1.reversal_axis() bar2 = Bar() bar2.add_xaxis(["中国", "美国", "俄罗斯"]) bar2.add_yaxis("GDP", [15, 35, 27], label_opts=LabelOpts(position="right")) # 数值靠右 bar2.reversal_axis() bar3 = Bar() bar3.add_xaxis(["中国", "美国", "俄罗斯"]) bar3.add_yaxis("GDP", [26, 40, 38], label_opts=LabelOpts(position="right")) # 数值靠右 bar3.reversal_axis() # 构建时间线对象 timeLine = Timeline({"theme": ThemeType.ESSOS}) timeLine.add(bar1, "点1") timeLine.add(bar2, "点2") timeLine.add(bar3, "点3") timeLine.add_schema( play_interval=1000, # 自动播放的时间间隔,单位毫秒 is_timeline_show=True, # 是否在自动播放的时候,显示时间线 is_auto_play=True, # 是否自动播放 is_loop_play=True # 是否循环自动播放 ) timeLine.render("时间线图表.html") ~~~ ![](https://img.kancloud.cn/bd/a3/bda38f34964491e4894810e604aee7bb_875x532.png)