Python框架-pygal之世界地图

摘要:
安装:pipinstallpygal_maps_此时,世界可以访问pygal.maps。world模块,并指定代码绘制国家Countrysimportpygal.maps。worldworldmap_chart=pygal.maps.world。World()世界地图_图表。title=“某些国家”世界地图.add(“F国家”

安装:


pip install pygal_maps_world

此时可以访问pygal.maps.world模块,并指定代码绘制国家

Countries

import pygal.maps.world

worldmap_chart = pygal.maps.world.World()
worldmap_chart.title = 'Some countries'
worldmap_chart.add('F countries', ['fr', 'fi'])
worldmap_chart.add('M countries', ['ma', 'mc', 'md', 'me', 'mg',
                                   'mk', 'ml', 'mm', 'mn', 'mo',
                                   'mr', 'mt', 'mu', 'mv', 'mw',
                                   'mx', 'my', 'mz'])
worldmap_chart.add('U countries', ['ua', 'ug', 'us', 'uy', 'uz'])
worldmap_chart.render_to_file('bar_chart.svg')

Python框架-pygal之世界地图第1张

指定某个国家的值:

import pygal.maps.world

worldmap_chart = pygal.maps.world.World()
worldmap_chart.title = 'Minimum deaths by capital punishement (source: Amnesty International)'
worldmap_chart.add('In 2012', {
  'af': 14,
  'bd': 1,
  'by': 3,
  'cn': 1000,
  'gm': 9,
  'in': 1,
  'ir': 314,
  'iq': 129,
  'jp': 7,
  'kp': 6,
  'pk': 1,
  'ps': 6,
  'sa': 79,
  'so': 6,
  'sd': 5,
  'tw': 6,
  'ae': 1,
  'us': 43,
  'ye': 28
})
worldmap_chart.render_to_file('bar_chart.svg')

Python框架-pygal之世界地图第2张

 

Continents

获取洲地图

import pygal.maps.world

supra = pygal.maps.world.SupranationalWorld()
supra.add('Asia', [('asia', 1)])
supra.add('Europe', [('europe', 1)])
supra.add('Africa', [('africa', 1)])
supra.add('North america', [('north_america', 1)])
supra.add('South america', [('south_america', 1)])
supra.add('Oceania', [('oceania', 1)])
supra.add('Antartica', [('antartica', 1)])
supra.render_to_file('bar_chart.svg')

Python框架-pygal之世界地图第3张



国家代码列表:
codeCountry
adAndorra
aeUnited Arab Emirates
afAfghanistan
alAlbania
amArmenia
aoAngola
aqAntarctica
arArgentina
atAustria
auAustralia
azAzerbaijan
baBosnia and Herzegovina
bdBangladesh
beBelgium
bfBurkina Faso
bgBulgaria
bhBahrain
biBurundi
bjBenin
bnBrunei Darussalam
boBolivia, Plurinational State of
brBrazil
btBhutan
bwBotswana
byBelarus
bzBelize
caCanada
cdCongo, the Democratic Republic of the
cfCentral African Republic
cgCongo
chSwitzerland
ciCote d’Ivoire
clChile
cmCameroon
cnChina
coColombia
crCosta Rica
cuCuba
cvCape Verde
cyCyprus
czCzech Republic
deGermany
djDjibouti
dkDenmark
doDominican Republic
dzAlgeria
ecEcuador
eeEstonia
egEgypt
ehWestern Sahara
erEritrea
esSpain
etEthiopia
fiFinland
frFrance
gaGabon
gbUnited Kingdom
geGeorgia
gfFrench Guiana
ghGhana
glGreenland
gmGambia
gnGuinea
gqEquatorial Guinea
grGreece
gtGuatemala
guGuam
gwGuinea-Bissau
gyGuyana
hkHong Kong
hnHonduras
hrCroatia
htHaiti
huHungary
idIndonesia
ieIreland
ilIsrael
inIndia
iqIraq
irIran, Islamic Republic of
isIceland
itItaly
jmJamaica
joJordan
jpJapan
keKenya
kgKyrgyzstan
khCambodia
kpKorea, Democratic People’s Republic of
krKorea, Republic of
kwKuwait
kzKazakhstan
laLao People’s Democratic Republic
lbLebanon
liLiechtenstein
lkSri Lanka
lrLiberia
lsLesotho
ltLithuania
luLuxembourg
lvLatvia
lyLibyan Arab Jamahiriya
maMorocco
mcMonaco
mdMoldova, Republic of
meMontenegro
mgMadagascar
mkMacedonia, the former Yugoslav Republic of
mlMali
mmMyanmar
mnMongolia
moMacao
mrMauritania
mtMalta
muMauritius
mvMaldives
mwMalawi
mxMexico
myMalaysia
mzMozambique
naNamibia
neNiger
ngNigeria
niNicaragua
nlNetherlands
noNorway
npNepal
nzNew Zealand
omOman
paPanama
pePeru
pgPapua New Guinea
phPhilippines
pkPakistan
plPoland
prPuerto Rico
psPalestine, State of
ptPortugal
pyParaguay
reReunion
roRomania
rsSerbia
ruRussian Federation
rwRwanda
saSaudi Arabia
scSeychelles
sdSudan
seSweden
sgSingapore
shSaint Helena, Ascension and Tristan da Cunha
siSlovenia
skSlovakia
slSierra Leone
smSan Marino
snSenegal
soSomalia
srSuriname
stSao Tome and Principe
svEl Salvador
sySyrian Arab Republic
szSwaziland
tdChad
tgTogo
thThailand
tjTajikistan
tlTimor-Leste
tmTurkmenistan
tnTunisia
trTurkey
twTaiwan (Republic of China)
tzTanzania, United Republic of
uaUkraine
ugUganda
usUnited States
uyUruguay
uzUzbekistan
vaHoly See (Vatican City State)
veVenezuela, Bolivarian Republic of
vnViet Nam
yeYemen
ytMayotte
zaSouth Africa
zmZambia
zwZimbabwe

洲列表:
codename
asiaAsia
europeEurope
africaAfrica
north_americaNorth America
south_americaSouth America
oceaniaOceania
antarticaAntartica


免责声明:文章转载自《Python框架-pygal之世界地图》仅用于学习参考。如对内容有疑问,请及时联系本站处理。

上篇腾讯云大数据套件Hermes-MR索引插件使用总结TiDB配置HAProxy负载均衡下篇

宿迁高防,2C2G15M,22元/月;香港BGP,2C5G5M,25元/月 雨云优惠码:MjYwNzM=

相关文章

Google的Web性能优化新方法——Diffable

来源于InfoQ: Google Maps的开发人员Josh和James最近提出并实现了一种Web性能优化新方法——Diffable, 即在浏览器加载Web页面时,促使其比较相关文件(Html、JavaScript等)在服务器端和客户端缓存区的版本并只下载差量(Deltas),降 低网络下载造成的延迟。本文简要介绍了Diffable方法的背景、原理、优势和...

freemarker:初识(搭建环境、对象、集合、索引、赋值、null、时间、宏定义)

1、Freemarker环境搭建 (1)导入依赖 <dependency> <groupId>org.freemarker</groupId> <artifactId>freemarker</artifactId> <version>2.3.16&l...

学习使用Bing Maps Silverlight Control(五):离线使用和自定义地图模式

6 离线使用 在笔记第一部分的时候就提到如果要使用Bing Maps Silverlight Control 进行开发,需要申请一个key,不让会显示一个错误提示出来。但是在实际开发或使用过程中,使用环境和地图数据可能不是在线的,但控件因为验证失败仍然会显示以下内容: 如何去掉这个提示?最简单的方式就是自己扩展一个Map控件,在其构造方法中将错误提示层给...

简易google地图api调用

代码如下: <!DOCTYPE html> <html> <head> <meta name="viewport" content="initial-scale=1.0, user-scalable=no" /> <style type="text/css">html { h...

Android系统Google Maps开发实例浅析

     Google Map(谷歌地图)是Google公司提供的电子地图服务。包括了三种视图:矢量地图、卫星图片、地形地图。对于Android系统来说,可以利用Google提供的地图服务来开发自己的一些应用。Google Map的服务体现在两个方面:地图API和位置API。使用Android Maps API(地图API)和Android Locatio...

Bing Maps 辅助工具 —— MapCruncher 简单使用学习

在使用Bing Maps控件的时候,一直都是使用的在线的地图Tile系统,这个。。必须要在线使用,如果想离线用咋办?一个就是把在线的地图下载下来,反正地址也有,做个工具下载呗,这个怎么做以后有机会再研究。这次主要讲解另一种办法,将自己的地图切块加载到Bing Maps控件上。具体说就是可以利用MapCruncher工具将一张完整的大图通过调整校正自动生成一...