最美情侣中文字幕电影,在线麻豆精品传媒,在线网站高清黄,久久黄色视频

歡迎光臨散文網(wǎng) 會(huì)員登陸 & 注冊

黑馬程序員python教程,8天python從入門到精通,學(xué)python看這套就

2023-06-26 19:28 作者:二月二的爆米花  | 我要投稿

P106 全國疫情地圖

注意所給txt文件中給的省份名稱都是簡寫,會(huì)導(dǎo)致無法生效。如:”北京“要改為“北京市”,”寧夏“要改為”寧夏回族自治區(qū)“,"香港"要改為”香港特別行政區(qū)“等等。

具體給出以下解決代碼:

import json

from pyecharts.charts import Map

from pyecharts.options import *

f = open("C:/Users/prophet/Desktop/new/可視化案例數(shù)據(jù)/地圖數(shù)據(jù)/疫情.txt","r",encoding="UTF-8")

content = f.read()

f.close()

data = json.loads(content)

province_data = data['areaTree'][0]['children']

# print(province_data)

map = Map()

Data = list()

for key in province_data:

province = tuple()

if key['name'] == "北京" or key['name'] == "天津" or key['name'] == "上海" or key['name'] == "重慶" :

province = (key['name']+"市" , key['total']['confirm'])

elif key['name'] == "內(nèi)蒙古" or key['name'] == "西藏" :

province = (key['name'] + "自治區(qū)", key['total']['confirm'])

elif key['name'] == "香港" or key['name'] == "澳門":

province = (key['name'] + "特別行政區(qū)", key['total']['confirm'])

elif key['name'] == "新疆":

province = (key['name'] + "維吾爾自治區(qū)", key['total']['confirm'])

elif key['name'] == "廣西":

province = (key['name'] + "壯族自治區(qū)", key['total']['confirm'])

elif key['name'] == "寧夏":

province = (key['name'] + "回族自治區(qū)", key['total']['confirm'])

else:

province = (key['name'] + "省", key['total']['confirm'])

Data.append(province)

print(Data)

map.add("各省份確診人數(shù)",Data,"china")

map.set_global_opts(

title_opts=TitleOpts(title="全國疫情地圖"),

visualmap_opts=VisualMapOpts(

is_show=True,

is_piecewise=True,

pieces=[

{"min": 1, "max": 99, "lable": "1~99", "color":"#CCFFFF"},

{"min": 100, "max": 999, "lable": "100~999", "color":"#FFFF99"},

{"min": 1000, "max": 4999, "lable": "1000~4999", "color":"#FF9966"},

{"min": 5000, "max": 9999, "lable": "5000~9999", "color":"#FF6666"},

{"min": 10000, "max": 99999, "lable": "10000~99999", "color":"#CC3333"},

{"min": 100000, "lable": "100000+", "color":"#990033"}

]

)

)

map.render("全國疫情地圖.html")

黑馬程序員python教程,8天python從入門到精通,學(xué)python看這套就的評(píng)論 (共 條)

分享到微博請遵守國家法律
宁陕县| 台东县| 寿阳县| 丰台区| 安达市| 佳木斯市| 鄯善县| 定日县| 蓬溪县| 邓州市| 沧源| 涟水县| 英山县| 开远市| 宁安市| 信丰县| 龙南县| 金门县| 新邵县| 阳信县| 枞阳县| 尼玛县| 文水县| 武宁县| 昌图县| 武陟县| 通河县| 南和县| 五常市| 蒲江县| 德钦县| 碌曲县| 马龙县| 克拉玛依市| 万荣县| 固安县| 霸州市| 舟山市| 云龙县| 宣恩县| 积石山|