国外优秀的企业网站景翔物流网站建设公司

当前位置: 首页 > news >正文

国外优秀的企业网站,景翔物流网站建设公司,如何能快速搜到新做网站链接,代写文章哪里找写手英雄联盟S14世界赛选手数据可视化 由于本学期有一门数据可视化课程#xff0c;课程结课作业要求完成一个数据可视化的小Demo#xff0c;于是便有了这个小项目#xff0c;课程老师要求比较简单#xff0c;只要求熟练运用可视化工具展示数据#xff0c;并不要求数据来源课程结课作业要求完成一个数据可视化的小Demo于是便有了这个小项目课程老师要求比较简单只要求熟练运用可视化工具展示数据并不要求数据来源因此这个小项目非常简单 项目简介 这是一个基于 PyEcharts 的数据可视化小项目展示了英雄联盟 S14 世界赛选手的关键数据表现适合作为数据可视化课程作业或兴趣项目。 项目特点 数据源权威来源于 Kaggle。涉及多种可视化类型包括柱状图、箱形图、雷达图等。共包含 14 个可视化图表分布在 3 个 HTML 页面中方便浏览与展示。 完整代码英雄联盟S14世界赛选手数据可视化 数据来源 数据来自 Kaggle 平台的 2024 LoL Championship Player Stats Swiss Stage。 数据涵盖选手的各项核心指标如 KDA、场均击杀、场均死亡等。细化到每分钟视野分数、野区控制等高级数据。 数据示例 TeamNamePlayerNamePositionGames…Penta KillsSolo KillsCountryFlashKeybindTop Esports369Top8…02ChinaDDplus KIAaimingAdc9…02South KoreaFMAD Lions KOIalvaroSupport5…00SpainD………………………LNG EsportszikaTop8…02ChinaD 效果展示 主要采用PyEcharts来完成数据可视化 数据总览 该模块主要有一个各队伍平均胜率的柱状图和全部选手的国籍分布饼图组成 # 计算各队伍平均胜率并将其转换为百分数形式乘以100并保留两位小数 team_win_rates df.groupby(TeamName)[Win rate].mean().reset_index() team_win_rates[Win rate] team_win_rates[Win rate].apply(lambda x: round(x * 100, 2)) print(team_win_rates)

绘制柱状图

bar Bar(init_optsopts.InitOpts(width1100px, height500px) ) bar.add_xaxis(team_win_rates[TeamName].tolist()) bar.add_yaxis(平均胜率, team_win_rates[Win rate].tolist(), category_gap60%) bar.set_global_opts(title_optsopts.TitleOpts(title各队伍平均胜率, subtitle),xaxis_optsopts.AxisOpts(axislabel_optsopts.LabelOpts(rotate45)),yaxis_optsopts.AxisOpts(name胜率, min_0, max_100),visualmap_optsopts.VisualMapOpts(is_showFalse, max_100, min_0) ) bar.render(static/charts/team_win_rates.html)# 国家分布

按照国家进行分组计算每个国家的选手数量

grouped_data df.groupby(Country).size()# 将结果转换为 DataFrame并命名为 Count country_data grouped_data.reset_index(nameCount) print(country_data) country_pie (Pie(init_optsopts.InitOpts(thememacarons)).add(, [list(z) for z in zip(country_data[Country], country_data[Count])]).set_global_opts(title_optsopts.TitleOpts(title)) ) country_pie.render(static/charts/country_distribution_chart.html)主要数据 该模块主要涉及了选手的各方位数据总览情况能够直观的观察各方面数据突出的选手其中包括场均击杀、 场均KDA、场均死亡、场均助攻、辅助视野综合得分、选手平均击杀、选手闪现按键情况 # 场均击杀 sorted_df df.sort_values(byAvg kills, ascendingFalse) avg_kills sorted_df[[PlayerName, Avg kills]] avg_kills_top10 avg_kills[0:10] print(avg_kills_top10)

创建Bar实例用于构建柱状图

bar Bar(init_optsopts.InitOpts(width600px, height300px) )

添加x轴数据即选手姓名

bar.add_xaxis(avg_kills_top10[PlayerName].tolist())

添加y轴数据即场均击杀数并设置系列名称为场均击杀数

bar.add_yaxis(场均击杀数, avg_kills_top10[Avg kills].tolist())

设置全局配置项

bar.set_global_opts(title_optsopts.TitleOpts(title场均击杀榜前十),xaxis_optsopts.AxisOpts(axislabel_optsopts.LabelOpts(rotate45), # 让x轴标签旋转45度避免文字重叠),yaxis_optsopts.AxisOpts(name场均击杀数), # 设置y轴名称visualmap_optsopts.VisualMapOpts(is_showFalse, max_6, min_4) ) bar.render(static/charts/avg_kills_top10.html)# KDA kda_top10 df.sort_values(byKDA, ascendingFalse)[[PlayerName, KDA]][0:10] print(kda_top10) bar Bar(init_optsopts.InitOpts(width600px, height300px) ) bar.add_xaxis(kda_top10[PlayerName].tolist())bar.add_yaxis(场均KDA, kda_top10[KDA].tolist())

设置全局配置项

bar.set_global_opts(title_optsopts.TitleOpts(title场均KDA前十),xaxis_optsopts.AxisOpts(axislabel_optsopts.LabelOpts(rotate45), # 让x轴标签旋转45度避免文字重叠),yaxis_optsopts.AxisOpts(name场均KDA), # 设置y轴名称visualmap_optsopts.VisualMapOpts(is_showFalse, max_10, min_6) ) bar.render(static/charts/kda_top10.html)# 场均死亡 deaths_top10 df.sort_values(byAvg deaths, ascendingFalse)[[PlayerName, Avg deaths]][0:10] print(deaths_top10) bar Bar(init_optsopts.InitOpts(width600px, height300px, thememacarons)) bar.add_xaxis(deaths_top10[PlayerName].tolist()) bar.add_yaxis(场均死亡, deaths_top10[Avg deaths].tolist())

设置全局配置项

bar.set_global_opts(title_optsopts.TitleOpts(title场均死亡前十),xaxis_optsopts.AxisOpts(axislabel_optsopts.LabelOpts(rotate45), # 让x轴标签旋转45度避免文字重叠),yaxis_optsopts.AxisOpts(name场均死亡), # 设置y轴名称visualmap_optsopts.VisualMapOpts(is_showFalse, max_6, min_4) ) bar.render(static/charts/deaths_top10.html)# 场均助攻 assists_top10 df.sort_values(byAvg assists, ascendingFalse)[[PlayerName, Avg assists]][0:10] print(assists_top10) bar Bar(init_optsopts.InitOpts(width600px, height300px, thememacarons) ) bar.add_xaxis(assists_top10[PlayerName].tolist())bar.add_yaxis(场均助攻, assists_top10[Avg assists].tolist())# 设置全局配置项 bar.set_global_opts(title_optsopts.TitleOpts(title场均助攻前十),xaxis_optsopts.AxisOpts(axislabel_optsopts.LabelOpts(rotate45), # 让x轴标签旋转45度避免文字重叠),yaxis_optsopts.AxisOpts(name场均助攻), # 设置y轴名称visualmap_optsopts.VisualMapOpts(is_showFalse, max_13, min_10) ) bar.render(static/charts/assists_top10.html)其中每分钟视野分数(VSPM)、每分钟赢得的野区分数(每分钟赢得的野区分数)、每分钟控制野区分数(Avg WCPM)、每分钟视野控制分数(Avg VWPM)各自的权重为1可自行更改 # 辅助野区视野排行 df[custom_sort] df[VSPM] * 25 df[Avg WPM] * 25 df[Avg WCPM] * 25 df[Avg VWPM] * 25 support_top_10 df.sort_values(bycustom_sort, ascendingFalse)[[PlayerName, VSPM, Avg WPM, Avg WCPM, Avg VWPM, custom_sort]][0:10] print(support_top_10)

创建堆叠柱状图

bar_stacked Bar(init_optsopts.InitOpts(width1000px, height400px, thememacarons) )

添加 X 轴数据选手名字

bar_stacked.add_xaxis(support_top_10[PlayerName].tolist())

添加堆叠柱状图的每一项数据

bar_stacked.add_yaxis(每分钟视野分数, support_top_10[VSPM].tolist(), stackstack1) bar_stacked.add_yaxis(每分钟赢得的野区分数, support_top_10[Avg WPM].tolist(), stackstack1) bar_stacked.add_yaxis(每分钟控制野区分数, support_top_10[Avg WCPM].tolist(), stackstack1) bar_stacked.add_yaxis(每分钟视野控制分数, support_top_10[Avg VWPM].tolist(), stackstack1)

设置全局配置

bar_stacked.set_global_opts(title_optsopts.TitleOpts(title辅助野区视野排行),yaxis_optsopts.AxisOpts(name),xaxis_optsopts.AxisOpts(name选手),legend_optsopts.LegendOpts(pos_leftright, orientvertical), # 设置图例在左侧 )

渲染图表到 HTML 文件

bar_stacked.render(static/charts/support_top_10.html)各位置场均击杀箱形图 # 准备箱线图数据 data [df[df[Position] pos][Avg kills].tolist() for pos in df[Position].unique()] print(data) boxplot Boxplot(init_optsopts.InitOpts(width600px, height400px) ) boxplot.add_xaxis(df[Position].unique().tolist()) boxplot.add_yaxis(平均击杀数, boxplot.prepare_data(data), itemstyle_optsopts.ItemStyleOpts(colorblack)) boxplot.set_global_opts(title_optsopts.TitleOpts(title不同位置选手平均击杀数分布),xaxis_optsopts.AxisOpts(axislabel_optsopts.LabelOpts(rotate45) # 此处也是修改为axislabel_opts),yaxis_optsopts.AxisOpts(name平均击杀数) ) boxplot.render(static/charts/avg_kills_distribution.html)# 闪现数据 flash df.groupby(FlashKeybind).size() flash_data flash.reset_index(nameflash_group) 创建饼图 pie Pie(init_optsopts.InitOpts(width400px, height400px) )

添加数据设置标签格式

pie.add(闪现按键使用情况,[list(z) for z in zip(flash_data[FlashKeybind].tolist(), flash_data[flash_group].tolist())],radius[30%, 60%],label_optsopts.LabelOpts(formatter{b}) )

设置标题

pie.set_global_opts(title_optsopts.TitleOpts(title闪现按键))# 渲染到本地文件 pie.render(static/charts/flash.html)我的主队 由于作者喜欢TheShy选手所以主队是WBG但是此次世界赛TheShy选手选择了休息但是也没有新的主队会所以主队依然是WBG 共有五个选手的雷达图 六大维度 KDAKP% (击杀参与率)CSPerMin (每分钟补刀数)GoldPerMin (每分钟经济)DPM (每分钟伤害)VSPM (每分钟视野分数) # 获取选手雷达图的数据 def get_player_render_data(player_name, file_name):player_data df[df[PlayerName] player_name][[KDA, KP%, CSPerMin, GoldPerMin, DPM, VSPM]].iloc[0]print(player_data)# 雷达图的维度attributes [KDA, KP%, CSPerMin, GoldPerMin, DPM, VSPM]values player_data.tolist()# 配置雷达图weradar Radar(init_optsopts.InitOpts(width350px, height350px))# 定义雷达图的每个维度radar.add_schema(schema[opts.RadarIndicatorItem(nameKDA, max_10),opts.RadarIndicatorItem(name击杀参与率, max_1),opts.RadarIndicatorItem(name每分钟补兵, max_10),opts.RadarIndicatorItem(name分钟收入金币, max_500),opts.RadarIndicatorItem(name分钟伤害, max_800),opts.RadarIndicatorItem(name分钟视野分, max_5)])# 添加数据系列并设置图例radar.add(player_name,[values],colorblue)# 设置全局选项radar.set_global_opts(title_optsopts.TitleOpts(titleplayer_name),legend_optsopts.LegendOpts(is_showTrue, orientvertical, pos_leftright))radar.render(file_name)

我的主队

get_player_render_data(crisp, static/charts/crisp_render_data.html) get_player_render_data(light, static/charts/light_render_data.html) get_player_render_data(xiaohu, static/charts/xiaohu_render_data.html) get_player_render_data(tarzan, static/charts/tarzan_render_data.html) get_player_render_data(breathe, static/charts/breathe_render_data.html)整体效果 整体效果就是将各个图表集中到了一起加了一些样式以一个静态网站来展示 完整效果请访问index.html 页面