Pygal Maps World Not Working

情到浓时终转凉″ 提交于 2019-12-04 13:23:36

In the recent versions of pygal, you start with the first four lines of this code:

from pygal.maps.world import World

wm = World()
wm.force_uri_protocol = 'http'

wm.title="Map of Central America"
wm.add('North America',{'ca': 84949494949,'mx': 494794164,'us': 99794616})

wm.render_to_file('map.svg')

When I use those first four lines and the rest of your code, your code runs and it highlights the United States and Mexico, but it highlights the Democratic Republic of the Congo rather than Canada. Change the country code to 'ca' for Canada! This then, of course, now shows North America rather than central America, so either change your title or change your country codes.

You can also use:

from pygal_maps_world.maps import World

wm = World()

if you open pygal_maps_world plugin physically, you will find a maps.py file and inside that file there is a "World" class. So you can reference that particular file by using module_name.file_name, which in this case is pygal_maps_world.maps and then import that class i.e. "World".

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!