当前位置:网站首页>数据可视化第四章答案
数据可视化第四章答案
2022-07-21 05:23:00 【花花王】
热狗大赛大胃王前三
from pyecharts import Pie
import pandas as pd
hotplace = pd.read_csv("hot-dog-places.csv", header=None)
hotplace = pd.DataFrame(hotplace.values.T, index=hotplace.columns, columns=['year', 'A', 'B', 'C'])
print (list(hotplace.A)[10])
pie = Pie(
"大胃王比赛历年比赛前三甲情况对比",
"2000-2010",
title_pos="center")
for i in range(len(list(hotplace.year))):
x = 10
y = 30
if i < 5:
x += 18 * i
if i >= 5:
x += 15 * (i - 5)
y = 70
pie.add(
"", ["第一名", "第二名", "第三名"], [list(hotplace.A)[i], list(hotplace.B)[i], list(hotplace.C)[i]],
center=[x, y], radius=[18, 24], label_pos='center', is_label_show=True, label_text_color=None, legend_top="center")
pie.render("大胃王比赛历年比赛前三甲情况对比.html")
柱状图堆叠示例
from pyecharts import Bar
import pandas as pd
pre_approval_rate=pd.read_csv("presidential_approval_rate.csv")
bar=Bar("柱状图数据堆叠示例")
bar.add("支持",pre_approval_rate['political_issue'],pre_approval_rate['support'],is_stack=True)
bar.add("反对",pre_approval_rate['political_issue'],pre_approval_rate['oppose'],is_stack=True)
bar.add("不发表意见",pre_approval_rate["political_issue"],pre_approval_rate['no_opinion'],xaxis_rotate=30,is_stack=True)
bar.render('3.堆叠柱形图.html')
人口老龄化
#encoding:utf-8
from pyecharts import Line
import pandas as pd
year_population_age=pd.read_csv('us_population_by_age.csv')
#面积折线图
line3=Line("人口老龄化",width=1000,height=600)
line3.add("5岁以下",year_population_age['year'], year_population_age['year_under5'],is_fill=True,
area_color='red',area_opacity=0.5,mark_point=['max'],is_stack=True)
#横坐标,纵坐标,is_fill:是否填充,area_color:填充颜色,area_opacity:透明度,mark_point:最大值,is_smooth:是否设置成圆滑曲线
line3.add("5至19岁",year_population_age['year'], year_population_age['year5_19'],is_fill=True,
area_color='blue',area_opacity=0.5,is_smooth=True,is_stack=True)
line3.add("20至44岁",year_population_age['year'], year_population_age['year20_44'],is_fill=True,
area_color='green',area_opacity=0.5,is_smooth=True,is_stack=True)
line3.add("45至64岁",year_population_age['year'], year_population_age['year45_64'],is_fill=True,
area_color='yellow',area_opacity=0.5,is_smooth=True,is_stack=True)
line3.add("65岁以上",year_population_age['year'], year_population_age['year65above'],is_fill=True,
area_color='purple',area_opacity=0.5,is_smooth=True,xaxis_rotate=30,legend_orient="vertical",legend_pos="right",is_stack=True)
#xaxis_rotate:x轴倾斜30°,legend_pos:标签的位置
line3.render(path='人口老龄化.html')
树图径向图
import os
import json
import codecs
from pyecharts import Tree
with codecs.open(os.path.join("flare.json"),"r",encoding="utf-8") as f:
j=json.load(f)
data=[j]
tree=Tree(width=1200,height=800)
tree.add("",data)
tree.render('树图.html')
边栏推荐
- the volume for a file has been externally altered so that the opened file is no longer valid
- ma.glasnost.orika.MappingException:No converter registered for conversion from Date to LocalDateTime
- VRRP虚拟路由冗余协议
- 一文搞懂高并发性能指标:QPS、TPS、RT、吞吐量
- 部署LVS-NAT集群
- After VMware turns on NAT mode / host only mode, the host cannot Ping the virtual machine
- 【自然语言处理和文本分析】基本信息检索技术中的全面扫描法和逐项翻转法。
- Go语言之return语句深入理解及defer、return的执行顺序
- 【特征选择】特征选择的几种方法
- kubectl get node运行时出现:Unable to connect to the server: x509: certificate signed by unknown authority
猜你喜欢
【特征学习】利用关联规则和神经网络进行建立新特征
Configure server development environment under virtual machine
路由中的RIP
VLAN高级技术
Detailed explanation of iptables
First acquaintance with JVM (I)
[feature learning] feature learning based on deep learning and word embedding
Introduction and configuration of raid
Cdh5 installing Kerberos authentication
VRRP virtual routing Redundancy Protocol
随机推荐
【自然语言处理和文本分析】基本信息检索技术中的全面扫描法和逐项翻转法。
R5为ISP,只能进行IP地址配置,其所有地址均配为共有IP地址
[natural language processing and text analysis] overview of natural language processing
[naturallanguageprocessing and text analysis] Why does our wordbag model not use the one hot encoding model when converting text unstructured data to structured data? How to improve it.
OSPF数据包
快速查看本机公网IP的几种方法
【自然語言處理與文本分析】用兩個項目案例介紹文本挖掘方法論。
[natural language processing and text analysis] unstructured text to structured data. BP neural network, back propagation neural network, the underlying principle of neural network optimization, gradi
Bond network mode
R5 is an ISP, which can only be configured with IP addresses. All its addresses are configured as common IP addresses
Host information collection script
BGP basic configuration and route aggregation
BGP related knowledge points
mount挂载不上,不提示任何信息
# QForkMasterInit: system error caught. error code=0x000005af, message=VirtualAllocEx failed.: unk
Go学习笔记—Channel通道
SQLite3 modifying column names
Strange response data
切换用户后,/etc/profile的配置不起效
VMware Workstation Pro 16 installation shows "setup failed to generate the SSL keys necessary to run VMware"