def DrawRadar(city_name): schema = [('最高气温', 45), ('气压', 1500), ('湿度', 100), ('最低气温', 45), ('PM2.5', 200)] data = qr.get_data(city_name) values = [[int(data['Htemperature']), int(data['QY']), int(data['SD'].strip('%')), int(data['Ltemperature']), int(data['pm25'])]] radar = Radar() radar.config(schema) radar.add('%s天气信息' % city_name, values, is_splitline=True, is_axisline_show=True) radar.render('weatherRadar.html')
def radar_demo(): radar = Radar() # data1 = [[12, 0, 2, 18, 0, 1]] radar_data1 = [2.0, 4.9, 7.0, 23.2, 25.6, 76.7, 135.6, 162.2, 32.6, 20.0, 6.4, 3.3]#降水量 # schema = [ # ("执行成功", 20), ("执行失败", 5), ("执行异常", 5), # ("回滚成功", 20), ("回滚失败", 5), ("执行中断", 5) # ] schema = [ ("Jan", 5), ("Feb", 10), ("Mar", 10), ("Apr", 50), ("May", 50), ("Jun", 200), ("Jul", 200), ("Aug", 200), ("Sep", 50), ("Oct", 50), ("Nov", 10), ("Dec", 5) ] radar.add_schema(schema) radar.add("执行状态", radar_data1) radar.render("/aa.html")
def drawRadar(arr, value, valuemax, name): radar = Radar(init_opts=opts.InitOpts( width="1280px", height="720px", bg_color="#CCCCCC")) v_max = [list(z) for z in zip(arr, valuemax)] radar.add_schema( schema=[opts.RadarIndicatorItem(name=k, max_=v) for k, v in v_max], splitarea_opt=opts.SplitAreaOpts( is_show=True, areastyle_opts=opts.AreaStyleOpts(opacity=1)), textstyle_opts=opts.TextStyleOpts(color="#fff"), ) radar.add( series_name=name, data=value, linestyle_opts=opts.LineStyleOpts(color="#CD0000"), ) radar.set_series_opts(label_opts=opts.LabelOpts(is_show=False)) radar.set_global_opts(title_opts=opts.TitleOpts(title=name), legend_opts=opts.LegendOpts()) radar.render("{0}.html".format(name))
def DrawRadar(title, data, savepath): print('正在分析评分构成...') radar = Radar() radar.set_series_opts(label_opts=opts.LabelOpts(is_show=False)) radar.set_global_opts( title_opts=opts.TitleOpts(title="Radar-评分分布统计雷达图", pos_left='center'), legend_opts=opts.LegendOpts(orient="vertical", pos_top="middle", pos_left="2%"), ) values = [[data[i][1] for i in range(len(data))]] # 把整个列表当做一个要画的东西 attrs = [data[i][0] for i in range(len(data))] # 改名字 attrs = list(map(int, attrs)) attrs = [str(i) + '星' for i in attrs] num = len(attrs) # 雷达图有几项 schema = [{"name": attrs[i], "max": 230} for i in (range(num))] radar.add_schema(schema=schema) radar.add('豆瓣评分构成', values) radar.render(os.path.join(savepath, '%s.html' % title))
def plot_radar(series_radiant, series_dire): c_schema = [{ "name": "控制", "max": 15, "min": 0 }, { "name": "核心", "max": 15, "min": 0 }, { "name": "辅助", "max": 15, "min": 0 }, { "name": "逃生", "max": 15, "min": 0 }, { "name": "爆发", "max": 15, "min": 0 }, { "name": "先手", "max": 15, "min": 0 }, { "name": "耐久", "max": 15, "min": 0 }, { "name": "推进", "max": 15, "min": 0 }] radar = Radar() radar.add_schema(schema=c_schema) radar.add("radiant", series_radiant, color="#f9713c") radar.add("dire", series_dire, color="#b3e4a1") radar.render("Rader.html")
def draw_radar_for_observation_result(): value = [[43, 58, 78, 65, 86, 63]] min_val = 0 max_val = 100 # 用于调整雷达各维度的范围大小 c_schema = [{"name": "交往能力", "max": max_val, "min": min_val, }, {"name": "感知能力", "max": max_val, "min": min_val, "color": "#ff0000"}, {"name": "运动能力", "max": max_val, "min": min_val, "color": "#000000"}, {"name": "注意力", "max": max_val, "min": min_val, "color": "#00ffff"}, {"name": "语言能力", "max": max_val, "min": min_val, "color": "#ff00ff"}, {"name": "自我照顾能力", "max": max_val, "min": min_val, "color": "#ff00ff"} ] # 画图 radar = Radar() radar.add_schema(c_schema, textstyle_opts=opts.TextStyleOpts(color="#3344ff")) radar.add(None, value, color="#f9713c", symbol='circle', label_opts=opts.LabelOpts(is_show=True), areastyle_opts=opts.AreaStyleOpts(opacity=0.5, color="#f9713c")) radar.set_global_opts(title_opts=opts.TitleOpts(title="Radar-基本示例")) radar.render("observation_result.html")
week = date_to_week(data['入网时间']) week1 = [week] radar = Radar() schema = [{ "name": '星期天', "max": 1000 }, { "name": '星期一', "max": 1000 }, { "name": '星期二', "max": 1000 }, { "name": '星期三', "max": 1000 }, { "name": '星期四', "max": 1000 }, { "name": '星期五', "max": 1000 }, { "name": '星期六', "max": 1000 }] radar.add(data=week1, series_name='入网时间') radar.add_schema(schema) radar.render('render.html')
def score_analyse_radar(chengji, stu, subject): score = pd.read_csv(chengji) radar = Radar() radar.render() pass
[3300, 13000, 25000, 30000, 48000, 24000]] v2 = [[5000, 14000, 28000, 31000, 42000, 21000]] radar = Radar() radar.add_schema(schema=[ opts.RadarIndicatorItem(name='销售', max_=6500), opts.RadarIndicatorItem(name='管理', max_=16000), opts.RadarIndicatorItem(name='信息技术', max_=30000), opts.RadarIndicatorItem(name='客服', max_=38000), opts.RadarIndicatorItem(name='研发', max_=52000), opts.RadarIndicatorItem(name='市场', max_=25000), ]) radar.add('预算分配', v1) radar.add('实际开销', v2) radar.set_global_opts(title_opts=opts.TitleOpts(title='Radar Sample')) radar.set_series_opts(label_opts=opts.LabelOpts(is_show=False)) radar.render('pyecharts-radar.html') # 词云图 words = [ ('Sam S Club', 10000), ('Macys', 6181), ('Amy Schumer', 4386), ('Jurassic World', 4055), ('Charter Communications', 2467), ] wordcloud = WordCloud() wordcloud.add('', words, word_size_range=[20, 100]) wordcloud.set_global_opts(title_opts=opts.TitleOpts(title='WordCloud Sample')) wordcloud.render('pyecharts-wordcloud.html') # 更多图表 https://pyecharts.org/#/zh-cn/basic_charts http://gallery.pyecharts.org/#/Boxplot/boxplot_light_velocity
def Cartography(): #创建地图 map = Map( init_opts=opts.InitOpts(width="1900px", height="900px", bg_color="#d0effa", page_title="全球新冠疫情_1")) map.add("确诊人数",[list(z) for z in zip(names_new, confirm)],is_map_symbol_show=False, maptype="world",label_opts=opts.LabelOpts(is_show=False),itemstyle_opts=opts.ItemStyleOpts(color="rgb(98,121,146)"))#地图区域颜色 map.set_global_opts(title_opts = opts.TitleOpts(title='全球新冠疫情确诊人数'),legend_opts=opts.LegendOpts(is_show=False), visualmap_opts=opts.VisualMapOpts(max_=2000000, is_piecewise=True, pieces=[ {"max": 3000000,"min": 500001,"label":">500000","color":"#460303"}, {"max": 500000, "min": 100001, "label": "100001-500000", "color": "#8A0808"}, {"max": 100000, "min": 10001, "label": "10001-100000", "color": "#B40404"}, {"max": 10000, "min": 1001, "label": "1001-10000", "color": "#DF0101"}, {"max": 1000, "min": 101, "label": "101-1000", "color": "#F78181"}, {"max": 100, "min": 1, "label": "1-100", "color": "#F5A9A9"}, {"max": 0, "min": 0, "label": "0", "color": "#fababa"}, ]) ) map.render('Global_new_crown_epidemic_map.html') #创建饼图 pie = Pie(init_opts=opts.InitOpts(width='1900px', height='900px',page_title="全球新冠疫情_2",bg_color="#fee4e7")) # 添加数据 pie.add("", [list(z) for z in zip(country_list, dead_list)], radius=['20%', '100%'],#设置内径外径 center=['60%', '65%'], rosetype='area')#圆心角相同,通过半径展现数据大小#rosetype='radius'圆心角展现数据百分比,半径展现数据大小 # 设置全局配置 pie.set_global_opts(title_opts=opts.TitleOpts(title='全球新冠疫情',subtitle='死亡人数超过\n5000的国家\n (除中国)', title_textstyle_opts=opts.TextStyleOpts(font_size=15,color= '#f40909'), subtitle_textstyle_opts= opts.TextStyleOpts(font_size=15,color= '#8a0b0b'), pos_right= 'center',pos_left= '57%',pos_top= '60%',pos_bottom='center'), legend_opts=opts.LegendOpts(is_show=False)) # 设置系列配置和颜色 pie.set_series_opts(label_opts=opts.LabelOpts(is_show=True, position='inside', font_size=13, formatter='{b}:{c}', font_style='italic', font_family='Microsoft YaHei')) pie.set_colors(color_matching) pie.render('Global_new_crown_epidemic_Rose.html') #创建雷达图 radar = Radar(init_opts=opts.InitOpts(width='1900px',height='900px',page_title="全球新冠疫情_3",bg_color="#d1eff3")) #由于雷达图传入的数据得为多维数据,所以这里需要做一下处理 radar_data1 = [list(dead_list)] radar_data2 = [list(heal_list)] radar.add_schema( schema=[ opts.RadarIndicatorItem(name='巴西', max_=8000), opts.RadarIndicatorItem(name='荷兰', max_=8000), opts.RadarIndicatorItem(name='伊朗', max_=20000), opts.RadarIndicatorItem(name='德国', max_=40000), opts.RadarIndicatorItem(name='比利时', max_=70000), opts.RadarIndicatorItem(name='英国', max_=80000), opts.RadarIndicatorItem(name='法国 ', max_=110000), opts.RadarIndicatorItem(name='西班牙', max_=150000), opts.RadarIndicatorItem(name='意大利', max_=170000), opts.RadarIndicatorItem(name='美国', max_=220000), ] ) radar.add("死亡人数",radar_data1,color='blue',areastyle_opts = opts.AreaStyleOpts(opacity = 0.2,color='blue')) radar.add("治愈人数",radar_data2,color='red',areastyle_opts=opts.AreaStyleOpts(opacity=0.3,color='red')) radar.set_series_opts(label_opts=opts.LabelOpts(is_show=True)) radar.set_global_opts(title_opts=opts.TitleOpts(title="死亡人数与治愈人数对比")) radar.render("Death_Versus_Heal.html")
def plt(key): """连接hbase""" connection = happybase.Connection(host="localhost", port=9090) """打开传输""" connection.open() """连接表""" basicFeaturesTable = happybase.Table('basicFeaturesTable', connection) socialAttributesTable = happybase.Table('socialAttributesTable', connection) consumptionFeaturesTable = happybase.Table('consumptionFeaturesTable', connection) internetFeaturesTable = happybase.Table('internetFeaturesTable', connection) consumptionCharacteristicsTable = happybase.Table( 'consumptionCharacteristicsTable', connection) internetBehaviorTable = happybase.Table('internetBehaviorTable', connection) """获取信息""" try: key_name = basicFeaturesTable.row(key, columns=["name"]) except: """连接hbase""" connection = happybase.Connection(host="localhost", port=9090) """打开传输""" connection.open() """连接表""" basicFeaturesTable = happybase.Table('basicFeaturesTable', connection) socialAttributesTable = happybase.Table('socialAttributesTable', connection) consumptionFeaturesTable = happybase.Table('consumptionFeaturesTable', connection) internetFeaturesTable = happybase.Table('internetFeaturesTable', connection) consumptionCharacteristicsTable = happybase.Table( 'consumptionCharacteristicsTable', connection) internetBehaviorTable = happybase.Table('internetBehaviorTable', connection) key_name = basicFeaturesTable.row(key, columns=["name"]) key_name = list(key_name.values()) key_name = key_name[0].decode() try: sInfo = socialAttributesTable.row(key, columns=["incLevel", "eduLevel"]) cInfo = consumptionFeaturesTable.row(key, columns=["CMLevel", "CTLevel"]) iInfo = internetFeaturesTable.row(key, columns=["intLevel"]) consumptionCharacteristicsInfo = consumptionCharacteristicsTable.row( key, columns=["commodity", "price", "date"]) internetBehaviorInfo = internetBehaviorTable.row \ (key, columns= ["date", "news", "communications", "entertainment", "domersticServices", "busApp", "toolUse"] ) except: """连接hbase""" connection = happybase.Connection(host="localhost", port=9090) """打开传输""" connection.open() """连接表""" basicFeaturesTable = happybase.Table('basicFeaturesTable', connection) socialAttributesTable = happybase.Table('socialAttributesTable', connection) consumptionFeaturesTable = happybase.Table('consumptionFeaturesTable', connection) internetFeaturesTable = happybase.Table('internetFeaturesTable', connection) consumptionCharacteristicsTable = happybase.Table( 'consumptionCharacteristicsTable', connection) internetBehaviorTable = happybase.Table('internetBehaviorTable', connection) sInfo = socialAttributesTable.row(key, columns=["incLevel", "eduLevel"]) cInfo = consumptionFeaturesTable.row(key, columns=["CMLevel", "CTLevel"]) iInfo = internetFeaturesTable.row(key, columns=["intLevel"]) consumptionCharacteristicsInfo = consumptionCharacteristicsTable.row( key, columns=["commodity", "price", "date"]) internetBehaviorInfo = internetBehaviorTable.row \ (key, columns= ["date", "news", "communications", "entertainment", "domersticServices", "busApp", "toolUse"] ) """消费情况图""" consumptionCharacteristicsValues = list( consumptionCharacteristicsInfo.values()) consumptionCharacteristicsValues = list( map(lambda x: x.decode(), consumptionCharacteristicsValues)) consumptionCharacteristicsValues[ int(len(consumptionCharacteristicsValues) / 3):-int(len(consumptionCharacteristicsValues) / 3)] \ = list(map(int, consumptionCharacteristicsValues[int(len(consumptionCharacteristicsValues) / 3): -int(len(consumptionCharacteristicsValues) / 3)])) consumptionCharacteristicsValues[-int(len(consumptionCharacteristicsValues) / 3):] \ = list(map(int, consumptionCharacteristicsValues[-int(len(consumptionCharacteristicsValues) / 3):])) consumptionCharacteristicsData = [] consumptionCharacteristicsData.append( consumptionCharacteristicsValues[:int( len(consumptionCharacteristicsValues) / 3)]) consumptionCharacteristicsData.append(consumptionCharacteristicsValues[ int(len(consumptionCharacteristicsValues) / 3):-int(len(consumptionCharacteristicsValues) / 3)]) consumptionCharacteristicsData.append(consumptionCharacteristicsValues[ -int(len(consumptionCharacteristicsValues) / 3):]) consumptionCharacteristicsData = pd.DataFrame( consumptionCharacteristicsData).T consumptionCharacteristicsData.columns = ["commodity", "date", "price"] consumptionCharacteristicsData.sort_values(by="date", inplace=True) consumptionCharacteristicsData_y = consumptionCharacteristicsData.loc[:, "date"].tolist( ) consumptionCharacteristicsData_y = list( map(str, consumptionCharacteristicsData_y)) consumptionCharacteristicsData_x = consumptionCharacteristicsData.loc[:, "price"].tolist( ) consumptionCharacteristicsData_commodity = consumptionCharacteristicsData.loc[:, "commodity"].tolist( ) quzhong_consumptionCharacteristicsData_y = list( set(consumptionCharacteristicsData_y)) if len(quzhong_consumptionCharacteristicsData_y) != len( consumptionCharacteristicsData_y): for i in range(len(quzhong_consumptionCharacteristicsData_y)): count_consumptionCharacteristicsData_y = consumptionCharacteristicsData_y. \ count(quzhong_consumptionCharacteristicsData_y[i]) if count_consumptionCharacteristicsData_y != 1: index = consumptionCharacteristicsData_y.index( quzhong_consumptionCharacteristicsData_y[i]) consumptionCharacteristicsData_y = consumptionCharacteristicsData_y[:index + 1] + \ consumptionCharacteristicsData_y[ index + count_consumptionCharacteristicsData_y:] consumptionCharacteristicsData_x[index] = sum( consumptionCharacteristicsData_x[ index:index + count_consumptionCharacteristicsData_y]) consumptionCharacteristicsData_x = consumptionCharacteristicsData_x[:index + 1] + \ consumptionCharacteristicsData_x[ index + count_consumptionCharacteristicsData_y:] consumptionCharacteristicsData_commodity[index] = \ ",".join( consumptionCharacteristicsData_commodity[index:index + count_consumptionCharacteristicsData_y]) consumptionCharacteristicsData_commodity \ = consumptionCharacteristicsData_commodity[:index + 1] + \ consumptionCharacteristicsData_commodity[index + count_consumptionCharacteristicsData_y:] consumptionCharacteristicsData_xx = \ [list(z) for z in zip(consumptionCharacteristicsData_x, consumptionCharacteristicsData_commodity)] scatter = Scatter(init_opts=opts.InitOpts(width="850px", height="380px")) scatter.add_xaxis(consumptionCharacteristicsData_y) scatter.add_yaxis("", consumptionCharacteristicsData_xx, color="red") scatter.set_global_opts( tooltip_opts=opts.TooltipOpts( trigger="item", axis_pointer_type="cross", formatter=JsCode( "function (params) {return '消费日期:' + params.name + ' <br/>消费金额:' + params.value[1] + '元 <br/>消费产品:' + params.value[2];}" )), yaxis_opts=opts.AxisOpts( name="消费金额", type_="value", name_textstyle_opts=opts.TextStyleOpts(color="white"), ########### axislabel_opts=opts.LabelOpts(formatter="{value} 元", border_color="white", color="white"), ######## axistick_opts=opts.AxisTickOpts(is_show=True), splitline_opts=opts.SplitLineOpts(is_show=True), ), xaxis_opts=opts.AxisOpts( name="消费日期", type_="category", name_textstyle_opts=opts.TextStyleOpts(color="white"), ########### axislabel_opts=opts.LabelOpts(border_color="white", color="white"), ############## axispointer_opts=opts.AxisPointerOpts(is_show=True, type_="shadow"), ), legend_opts=opts.LegendOpts(is_show=False)) scatter.set_series_opts(label_opts=opts.LabelOpts(is_show=False)) line = Line(init_opts=opts.InitOpts(width="850px", height="380px")) line.add_xaxis(consumptionCharacteristicsData_y) line.add_yaxis(series_name="", y_axis=consumptionCharacteristicsData_x, color="red") scatter.overlap(line) scatter.render("./static/html/pictureConsumptionCharacteristics.html") """互联网行为图""" internetBehaviorInfoKeys = list(internetBehaviorInfo.keys()) internetBehaviorInfoKeys = list( map(lambda x: x.decode(), internetBehaviorInfoKeys)) internetBehaviorInfoKeys = list( map(lambda x: x[:x.index(':')], internetBehaviorInfoKeys)) internetBehaviorInfoValues = list(internetBehaviorInfo.values()) internetBehaviorInfoValues = list( map(lambda x: x.decode(), internetBehaviorInfoValues)) internetBehaviorInfoValues = list(map(int, internetBehaviorInfoValues)) internetBehaviorData = [] splitNum = int(len(internetBehaviorInfoValues) / 7) internetBehaviorData.append(internetBehaviorInfoValues[:splitNum]) internetBehaviorData.append(internetBehaviorInfoValues[splitNum:2 * splitNum]) internetBehaviorData.append(internetBehaviorInfoValues[2 * splitNum:3 * splitNum]) internetBehaviorData.append(internetBehaviorInfoValues[3 * splitNum:4 * splitNum]) internetBehaviorData.append(internetBehaviorInfoValues[4 * splitNum:5 * splitNum]) internetBehaviorData.append(internetBehaviorInfoValues[5 * splitNum:6 * splitNum]) internetBehaviorData.append(internetBehaviorInfoValues[6 * splitNum:7 * splitNum]) internetBehaviorData = pd.DataFrame(internetBehaviorData).T internetBehaviorData.columns = [ internetBehaviorInfoKeys[0], internetBehaviorInfoKeys[splitNum], internetBehaviorInfoKeys[2 * splitNum], internetBehaviorInfoKeys[3 * splitNum], internetBehaviorInfoKeys[4 * splitNum], internetBehaviorInfoKeys[5 * splitNum], internetBehaviorInfoKeys[6 * splitNum] ] internetBehaviorData.sort_values(by="date", inplace=True) internetBehaviorData_y = internetBehaviorData.loc[:, "date"].tolist() internetBehaviorData_y = list(map(str, internetBehaviorData_y)) bar = Bar(init_opts=opts.InitOpts(width="800px", height="380px")) bar.add_xaxis(internetBehaviorData_y) bar.add_yaxis(series_name="新闻资讯", yaxis_data=internetBehaviorData.loc[:, "news"].tolist(), stack="stack") bar.add_yaxis( series_name="通信交流", yaxis_data=internetBehaviorData.loc[:, "communications"].tolist(), stack="stack") bar.add_yaxis( series_name="娱乐休闲", yaxis_data=internetBehaviorData.loc[:, "entertainment"].tolist(), stack="stack") bar.add_yaxis( series_name="生活服务", yaxis_data=internetBehaviorData.loc[:, "domersticServices"].tolist(), stack="stack") bar.add_yaxis(series_name="商务应用", yaxis_data=internetBehaviorData.loc[:, "busApp"].tolist(), stack="stack") bar.add_yaxis(series_name="工具使用", yaxis_data=internetBehaviorData.loc[:, "toolUse"].tolist(), stack="stack") bar.set_series_opts(label_opts=opts.LabelOpts(is_show=False)) bar.set_global_opts( tooltip_opts=opts.TooltipOpts(is_show=True, trigger="axis", axis_pointer_type="cross"), xaxis_opts=opts.AxisOpts( name="日期", name_textstyle_opts=opts.TextStyleOpts(color="white"), ########### type_="category", axislabel_opts=opts.LabelOpts(border_color="white", color="white"), ############# axispointer_opts=opts.AxisPointerOpts(is_show=True), ), yaxis_opts=opts.AxisOpts( name="时间", name_textstyle_opts=opts.TextStyleOpts(color="white"), type_="value", min_=0, max_=24, interval=4, axislabel_opts=opts.LabelOpts(formatter="{value} 小时", border_color="white", color="white"), ########### axistick_opts=opts.AxisTickOpts(is_show=True), ), datazoom_opts=opts.DataZoomOpts(type_="inside"), legend_opts=opts.LegendOpts(is_show=True, textstyle_opts=opts.TextStyleOpts( border_color="white", color="wihte"), orient='horizontal')) bar.render("./static/html/pictureInternetBehavior.html") """个人特征图""" sValue = list(sInfo.values()) sValue = list(map(lambda x: x.decode(), sValue)) cValue = list(cInfo.values()) cValue = list(map(lambda x: x.decode(), cValue)) iValue = list(iInfo.values()) iValue = list(map(lambda x: x.decode(), iValue)) value = sValue + cValue + iValue value = list(map(int, value)) value = [value[1], value[2], value[3], value[0], value[4]] value = [value] rader = Radar(init_opts=opts.InitOpts(width="350px", height="350px")) rader.add_schema(schema=[ opts.RadarIndicatorItem(name="收入指数", max_=5), opts.RadarIndicatorItem(name="消费金\n额指数", max_=5), opts.RadarIndicatorItem(name="消费次数指数", max_=5), opts.RadarIndicatorItem(name="学历指数", max_=5), opts.RadarIndicatorItem(name="网络依\n赖指数", max_=5), ], shape='polygon') rader.add(series_name=key_name, data=value) rader.set_global_opts(legend_opts=opts.LegendOpts(is_show=False)) rader.render("./static/html/pictureCompositiveInfo.html")
def draw_radar(season_x, season_name, filechart, seasonareacolor, seasonlinecolor): # 建立schema的json文件 season_x.columns = [season_name] season_index = season_x.index.to_list() # print(season_index) # n_max, n_min = max(season_x), min(season_x) n_max = max(enumerate(season_x[0]), key=operator.itemgetter(1))[1] n_min = min(enumerate(season_x[0]), key=operator.itemgetter(1))[1] # 用于获取对象的哪些维的数据 # print(n_max, n_min) df_season = pd.DataFrame({'name': season_index}) df_season['max'], df_season['min'] = n_max, n_min # season_js = df_season.to_json(orient='records') # print(season_js) # 设置16方位, 逆时针排序 season_js = [ {"name": "N", "max": n_max, "min": n_min}, {"name": "NNW", "max": n_max, "min": n_min}, {"name": "NW", "max": n_max, "min": n_min}, {"name": "WNW", "max": n_max, "min": n_min}, {"name": "W", "max": n_max, "min": n_min}, {"name": "WSW", "max": n_max, "min": n_min}, {"name": "SW", "max": n_max, "min": n_min}, {"name": "SSW", "max": n_max, "min": n_min}, {"name": "S", "max": n_max, "min": n_min}, {"name": "SSE", "max": n_max, "min": n_min}, {"name": "SE", "max": n_max, "min": n_min}, {"name": "ESE", "max": n_max, "min": n_min}, {"name": "E", "max": n_max, "min": n_min}, {"name": "ENE", "max": n_max, "min": n_min}, {"name": "NE", "max": n_max, "min": n_min}, {"name": "NNE", "max": n_max, "min": n_min}, ] # 设置数据 fengsus = season_x[0].to_list() data_fengsu = [{'value': fengsus, 'name': '风频数'}] # print(data_fengsu) charts = Radar() charts.set_colors(['#4587E7']) # 设置颜色 charts.add_schema(schema=season_js, shape='circle', center=['50%', '50%'], radius='80%', angleaxis_opts=opts.AngleAxisOpts( min_=0, # 坐标轴刻度最小值 max_=360, # 坐标轴刻度最大值 is_clockwise=True, interval=22.5, # 强制设置坐标轴分割间隔 axistick_opts=opts.AxisTickOpts(is_show=False), axislabel_opts=opts.LabelOpts(is_show=False,), # 坐标轴线标签配置项 axisline_opts=opts.AxisLineOpts(is_show=True), # 坐标轴线风格配置项 splitline_opts=opts.SplitLineOpts(is_show=True) # 分割线配置项 ), radiusaxis_opts=opts.RadiusAxisOpts( min_=n_min, # 坐标轴刻度最小值 max_=n_max, # 坐标轴刻度最大值 interval=2, # 强制设置坐标轴分割间隔 splitarea_opts=opts.SplitAreaOpts( is_show=True, areastyle_opts=opts.AreaStyleOpts(opacity=0.2, ) ), splitline_opts=opts.SplitLineOpts(is_show=True, linestyle_opts=opts.LineStyleOpts(is_show=True, width=0.5, color='grey')), axislabel_opts=opts.LabelOpts(is_show=True, font_size=12, color='grey'), # 坐标轴线标签配置项 ), polar_opts=opts.PolarOpts(), splitarea_opt=opts.SplitAreaOpts(is_show=True), splitline_opt=opts.SplitLineOpts(is_show=False), # 分割线配置项 textstyle_opts=opts.TextStyleOpts(color='black', font_size=14) ) charts.add(series_name='%s玫瑰图' % season_name, # 系列名称 data=data_fengsu, # 系列数据 areastyle_opts=opts.AreaStyleOpts(opacity=0.5, # 系列面样式设置 color=seasonareacolor), linestyle_opts=opts.LineStyleOpts(width=2, # 系列线样式设置 color=seasonlinecolor), label_opts=opts.LabelOpts(is_show=False), ) # 系列标签设置 charts.render(filechart)