基于Python繪制世界疫情地圖詳解
世界疫情數(shù)據(jù)下載請點(diǎn)擊》》:疫情數(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利用PyAutoGUI實現(xiàn)自動點(diǎn)贊
PyAutoGUI作為一個 GUI 操作的神器,我們看到了它的操作都很簡單,非常通俗易懂,基本上看到函數(shù)就能知道它的功效。本文將用它實現(xiàn)批量給知乎的文章點(diǎn)贊,感興趣的可以了解一下2022-06-06
Python基礎(chǔ)學(xué)習(xí)之函數(shù)和代碼復(fù)用詳解
函數(shù)能提高應(yīng)用的模塊性,和代碼的重復(fù)利用率,下面這篇文章主要給大家介紹了關(guān)于Python基礎(chǔ)學(xué)習(xí)之函數(shù)和代碼復(fù)用的相關(guān)資料,文中通過實例代碼介紹的非常詳細(xì),需要的朋友可以參考下2022-08-08
Python實現(xiàn)加解密,編碼解碼和進(jìn)制轉(zhuǎn)換(最全版)
這篇文章主要為大家詳細(xì)介紹了Python實現(xiàn)加解密、編碼解碼、進(jìn)制轉(zhuǎn)換、字符串轉(zhuǎn)換的最全版操作方法,文中的示例代碼講解詳細(xì),大家可以收藏一下2023-01-01
在Django中創(chuàng)建動態(tài)視圖的教程
這篇文章主要介紹了在Django中創(chuàng)建動態(tài)視圖的教程,Django是Python重多人氣框架中最為著名的一個,需要的朋友可以參考下2015-07-07

