基于Python繪制世界疫情地圖詳解
世界疫情數(shù)據(jù)下載請點擊》》:疫情數(shù)據(jù)下載
注:此數(shù)據(jù)是2022年3月12號的結(jié)果,其中透明的地方代表確診人數(shù)小于10萬人,白色的地方代表無該國家的數(shù)據(jù)。
最終效果:


下載需要的python包:
pip install echarts-countries-pypkg pip install echarts-china-provinces-pypkg pip install echarts-countries-china-cities-pypkg
import seaborn as sns import numpy as np import pandas as pd import matplotlib as mpl import matplotlib.pyplot as plt %matplotlib inline plt.rcParams['font.sans-serif']=['Microsoft YaHei'] # 用來正常顯示中文標(biāo)簽 plt.rcParams['axes.unicode_minus']=False # 用來正常顯示負(fù)號 from datetime import datetime plt.figure(figsize=(16,10)) import pyecharts.options as opts from pyecharts.charts import Line from pyecharts.faker import Faker from pyecharts.charts import Bar import os from pyecharts.options.global_options import ThemeType
alldfgbcountrysum=pd.read_csv("alldfgbcountrysum.csv",encoding='utf-8-sig')
alldfregiongbmax=alldfgbcountrysum.groupby(alldfgbcountrysum['Country_Region'])['Confirmed','Recovered','Deaths','Date'].max()
alldfregiongbmax.reset_index(inplace=True)
alldfregiongbmax.loc[(alldfregiongbmax['Country_Region']=='US','Country_Region')]='United States' alldfregiongbmax[alldfregiongbmax['Countey_Region']=='United States']
alldfregiongbmax的數(shù)據(jù):

地圖繪制:
# 地圖繪制
from pyecharts import options as opts
from pyecharts.charts import Map
import random
regions=alldfregiongbmax['Country_Region'].to_list()
regions2=[]
for i in range(len(regions)):
regions2.append(regions[i])
regions2
data=[(i,alldfregiongbmax[alldfregiongbmax['Country_Region']==i]['Confirmed'].to_list()) for i in regions2]
data
imap=(
Map(
init_opts=opts.InitOpts(bg_color='rgba(255,250,205,0.2)',
width='1400px',
height='1000px',
page_title='疫情數(shù)據(jù)',
theme=ThemeType.ROMA
)
)
.add("確診人數(shù)",data,"world",zoom=1)
.set_global_opts(
title_opts=opts.TitleOpts(title="世界疫情數(shù)據(jù)--地圖繪制"),
legend_opts=opts.LegendOpts(is_show=True),
visualmap_opts=opts.VisualMapOpts(max_=80000000,min_=100000,is_piecewise=True,split_number=10),
) # 通過更改max_ ,min_ 來調(diào)整地圖的顏色
)
imap.render_notebook()

到此這篇關(guān)于基于Python繪制世界疫情地圖詳解的文章就介紹到這了,更多相關(guān)Python地圖內(nèi)容請搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!
相關(guān)文章
Python處理字符串的常用函數(shù)實例總結(jié)
在數(shù)據(jù)分析中,特別是文本分析中,字符處理需要耗費極大的精力,因而了解字符處理對于數(shù)據(jù)分析而言,也是一項很重要的能力,這篇文章主要給大家介紹了關(guān)于Python處理字符串的常用函數(shù),需要的朋友可以參考下2021-11-11
Python讀取Hive數(shù)據(jù)庫實現(xiàn)代碼詳解
這篇文章主要介紹了Python讀取Hive數(shù)據(jù)庫實現(xiàn)代碼,本文給大家介紹的非常詳細(xì),對大家的學(xué)習(xí)或工作具有一定的參考借鑒價值,需要的朋友可以參考下2023-03-03
python多項式擬合之np.polyfit 和 np.polyld詳解
這篇文章主要介紹了python多項式擬合之np.polyfit 和 np.polyld的實例代碼,python數(shù)據(jù)擬合主要可采用numpy庫,庫的安裝可直接用pip install numpy等,需要的朋友跟隨小編一起學(xué)習(xí)吧2020-02-02
Python樹莓派學(xué)習(xí)筆記之UDP傳輸視頻幀操作詳解
這篇文章主要介紹了Python樹莓派學(xué)習(xí)筆記之UDP傳輸視頻幀操作,結(jié)合實例形式詳細(xì)分析了Python樹莓派編程中使用UDP協(xié)議進(jìn)行視頻幀傳輸?shù)南嚓P(guān)操作技巧與注意事項,需要的朋友可以參考下2019-11-11
Pytorch損失函數(shù)torch.nn.NLLLoss()的使用
這篇文章主要介紹了Pytorch損失函數(shù)torch.nn.NLLLoss()的使用,具有很好的參考價值,希望對大家有所幫助。如有錯誤或未考慮完全的地方,望不吝賜教2023-02-02
Numpy中np.random.rand()和np.random.randn() 用法和區(qū)別詳解
這篇文章主要介紹了Numpy中np.random.rand()和np.random.randn() 用法和區(qū)別詳解,文中通過示例代碼介紹的非常詳細(xì),對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧2020-10-10

