Input

The input for worldmap is described in the docstrings worldmap.worldmap.plot() and is as following:

Color countries.

param county_names

Names of countries or regions within a county to be colored.

type county_names

list of str

param map_name

Name of the county to be colored. The default is ‘world’.

type map_name

str, optional

param opacity

Set the opacity for each of the map_name(s). The default is []. If values are >1, it is scaled between [0-1] 0 = full transparancy, 1= no transparancy

type opacity

list of float [0-1], optional

param cmap

Colormap to be used. Colors is set on the unique county_names. The default is ‘Set1’. All colormaps can be reverted using the “_r”: e.g., binary_r [‘#ffffff’,’#1f1f1f’]: Each map with a specified color [‘#ff0000’]: All maps have a red color ‘Set1’ : Discrete colors (default) ‘Pastel1’ : Discrete colors ‘Paired’ : Discrete colors ‘bwr’ : Blue-white-red ‘RdBu’ : Red-white-Blue ‘binary’ : black-white ‘seismic’ : Blue-white-red ‘rainbow’ : all coors ‘Blues’ : white-to-blue

type cmap

str, optional

param filename

filepath to write the output file. The default is ‘custom_map.svg’.

type filename

str, optional

param showfig

Open figure in browser. The default is False.

type showfig

bool, optional

param verbose

print message to screen. The default is True.

type verbose

int, optional

returns

Containing dataframe with the plotted regions, with its colors and the filename.

rtype

tuple (pd.DataFrame, filename)

Examples

>>> # Import library
>>> import worldmap as wm
>>>
>>> # Set the regions to plot
>>> region = ['zeeland','Overijssel', 'flevoland']
>>>
>>> # Color the regions
>>> opacity = [0.1, 0.2, 0.6]
>>>
>>> # Create the SVG
>>> results = wm.plot(region, opacity=opacity, cmap='Set1', map_name='netherlands')

Output

The output of worldmap worldmap.worldmap.plot() is a tuple containing the following information:

  • pd.DataFrame : Dataframe with the plotted regions, and colors

  • filename : Filename

print(results[0])

#     county_names        SVGcity  opacity     fill
# 0        zeeland        zeeland      0.4  #e41a1c
# 1     Overijssel     overijssel      0.6  #377eb8
# 2      flevoland      flevoland      0.9  #4daf4a
# 3        Drenthe        Drenthe      1.0  #CCCCCC
# 4      Friesland      Friesland      1.0  #CCCCCC
# 5     Gelderland     Gelderland      1.0  #CCCCCC
# 6      Groningen      Groningen      1.0  #CCCCCC
# 7        Limburg        Limburg      1.0  #CCCCCC
# 8  Noord-Brabant  Noord-Brabant      1.0  #CCCCCC
# 9  Noord-Holland  Noord-Holland      1.0  #CCCCCC
# 10       Utrecht        Utrecht      1.0  #CCCCCC
# 11  Zuid-Holland   Zuid-Holland      1.0  #CCCCCC

print(results[1])
'Netherlands_map.svg'