Pyecharts-学习笔记系列之EffectScatter的各种图形示例
# -*- coding: utf-8 -*-"""Take small actions every day to advance your dreams."""from pyecharts import options as optsfrom pyecharts.globals import SymbolTypefrom pyecharts.charts import EffectScatterdata [[10.0, 8.04],[8.0, 6.95],[13.0, 7.58],[9.0, 8.81],[11.0, 8.33],[14.0, 9.96],[6.0, 7.24],[4.0, 4.26],[12.0, 10.84],[7.0, 4.82],[5.0, 5.68],]data.sort(keylambda x: x[0],reverse False) # 这里的lambda是默认的别管他后面的x:x[0]代表字典的键key给sort排序x:x[1]代表字典的值#values给sort排序reversetrue表示降序reversefalse表示逆序。x_data [d[0] for d in data]y_data [d[1] for d in data]y_data_1 [d[1] *1.3 for d in data]y_data_2 [d[1] /1.3 for d in data]y_data_3 [d[1] /1.6 for d in data]y_data_4 [d[1] *1.6 for d in data]y_data_5 [d[1] *1.9 for d in data]# 注意X轴和Y轴的赋值参数名格式不一样# X轴xaxis_data# Y轴y_axis# PYECharts 提供的标记类型包括 RECT, ROUND_RECT, TRIANGLE, DIAMOND, ARROW, none 与Echarts不同 # ECharts 提供的标记类型包括 circle, rect, roundRect, triangle, diamond, pin, arrow, nonec (EffectScatter(init_optsopts.InitOpts(width"1200px", height"800px")).add_xaxis(xaxis_datax_data).add_yaxis("type_1",y_axisy_data,symbolSymbolType.ARROW,symbol_size6,color"blue") # 添加brush_type,scale,period会报错.add_yaxis("type_2",y_axisy_data_1,symbolSymbolType) # 默认圆形,.add_yaxis("type_3",y_axisy_data_2,symbolSymbolType.DIAMOND).add_yaxis("type_4",y_axisy_data_3,symbolSymbolType.RECT).add_yaxis("type_5",y_axisy_data_4,symbolSymbolType.ROUND_RECT) .add_yaxis("type_6",y_axisy_data_1,symbolSymbolType.TRIANGLE) .set_global_opts(title_optsopts.TitleOpts(title"不同涟漪发散效果散点图"),xaxis_optsopts.AxisOpts(splitline_optsopts.SplitLineOpts(is_showTrue)),yaxis_optsopts.AxisOpts(splitline_optsopts.SplitLineOpts(is_showTrue)),).render("不同涟漪发散效果散点图_2.html"))
注意
#注意X轴和Y轴的赋值参数名格式不一样 X轴xaxis_data #Y轴y_axis PYECharts 提供的标记类型包括 ‘RECT’, ‘ROUND_RECT’, ‘TRIANGLE’, ‘DIAMOND’, ‘ARROW’,