pyecharts的注意事项、Map类的具体名称列表

这两天给同学写了个从Excel表格中导出数据并生成可视化数据地图(热力图)的简单python代码,用到了pyecharts库,简单记录一下过程。相应代码已经发布到GlobalVisualHeatMap-github

pyecharts的不同版本差异较大,建议搜索教程或查看官方文档时特别关注一下版本。

各种参数的解释可以在官方文档中找到,这里不再赘述,渲染生成图片也可以按照渲染图片的官方教程来,比较简单。

我的代码中主要使用了Map类,可以根据输入的数据为不同的地区渲染不同的颜色。也使用了Levenshtein,用于国家名的模糊查询与匹配。其实在pyecharts的代码中我发现了模糊查询的代码,但可能因为输入差别过大,很多值无法匹配,于是自己做了匹配。

输出图片的一部分

但是我目前并没有找到完整的所有国家的名称列表(用于数据匹配),于是随意生成了一个html文件,从加载的js文件中提取了国家名称列表。

列表如下,也可以在github找到txt文件,希望能为需要的人提供一些帮助。

Zimbabwe
Zambia
Yemen
Vietnam
Venezuela
Vatican City
Vanuatu
Uzbekistan
Uruguay
Micronesia
Marshall Islands
Northern Mariana Islands
United States Virgin Islands
Guam
American Samoa
Puerto Rico
United States
South Georgia and the South Sandwich Islands
British Indian Ocean Territory
Saint Helena
Pitcairn Islands
Anguilla
Falkland Islands
Cayman Islands
Bermuda
British Virgin Islands
Turks and Caicos Islands
Montserrat
Jersey
Guernsey
Isle of Man
United Kingdom
United Arab Emirates
Ukraine
Uganda
Turkmenistan
Turkey
Tunisia
Trinidad and Tobago
Tonga
Togo
East Timor
Thailand
Tanzania
Tajikistan
Syria
Switzerland
Sweden
Eswatini
Suriname
South Sudan
Sudan
Sri Lanka
Spain
South Korea
South Africa
Somalia
Somaliland
Solomon Islands
Slovakia
Slovenia
Singapore
Sierra Leone
Seychelles
Serbia
Senegal
Saudi Arabia
São Tomé and Príncipe
San Marino
Samoa
Saint Vincent and the Grenadines
Saint Lucia
Saint Kitts and Nevis
Rwanda
Russia
Romania
Qatar
Portugal
Poland
Philippines
Peru
Paraguay
Papua New Guinea
Panama
Palau
Pakistan
Oman
Norway
North Korea
Nigeria
Niger
Nicaragua
New Zealand
Niue
Cook Islands
Netherlands
Aruba
Curaçao
Nepal
Nauru
Namibia
Mozambique
Morocco
Western Sahara
Montenegro
Mongolia
Moldova
Monaco
Mexico
Mauritius
Mauritania
Malta
Mali
Maldives
Malaysia
Malawi
Madagascar
North Macedonia
Luxembourg
Lithuania
Liechtenstein
Libya
Liberia
Lesotho
Lebanon
Latvia
Laos
Kyrgyzstan
Kuwait
Kosovo
Kiribati
Kenya
Kazakhstan
Jordan
Japan
Jamaica
Italy
Israel
Palestine
Ireland
Iraq
Iran
Indonesia
India
Iceland
Hungary
Honduras
Haiti
Guyana
Guinea-Bissau
Guinea
Guatemala
Grenada
Greece
Ghana
Germany
Georgia
Gambia
Gabon
France
Saint Pierre and Miquelon
Wallis and Futuna
Saint Martin (French part)
Saint Barthélemy
French Polynesia
New Caledonia
French Southern and Antarctic Lands
Åland Islands
Finland
Fiji
Ethiopia
Estonia
Eritrea
Equatorial Guinea
El Salvador
Egypt
Ecuador
Dominican Republic
Dominica
United States Minor Outlying Islands
Djibouti
Greenland
Faroe Islands
Denmark
Czechia
Northern Cyprus
Cyprus
Cuba
Croatia
Ivory Coast
Costa Rica
Democratic Republic of the Congo
Republic of the Congo
Comoros
Colombia
China
Chile
Chad
Central African Republic
Cape Verde
Canada
Cameroon
Cambodia
Myanmar
Burundi
Burkina Faso
Bulgaria
Brunei
Brazil
Botswana
Bosnia and Herzegovina
Bolivia
Bhutan
Benin
Belize
Belgium
Belarus
Barbados
Bangladesh
Bahrain
Bahamas
Azerbaijan
Austria
Australia
Christmas Island
Heard Island and McDonald Islands
Norfolk Island
Ashmore and Cartier Islands
Armenia
Argentina
Antigua and Barbuda
Angola
Andorra
Algeria
Albania
Afghanistan
Siachen Glacier
Sint Maarten (Dutch part)
Tuvalu

tips:国家名由js文件直接生成,未做任何干预,名称错误与博主无关。