コード例 #1
0
def plot_global_sex_ratio():
    below_20 = country_ratios.loc[country_ratios["Sex"] <= 0.20]
    below_20 = below_20.reset_index()
    below_40 = country_ratios.loc[country_ratios["Sex"] <= 0.40].loc[
        country_ratios["Sex"] > 0.20]
    below_40 = below_40.reset_index()
    below_60 = country_ratios.loc[country_ratios["Sex"] > 0.40].loc[
        country_ratios["Sex"] <= 0.60]
    below_60 = below_60.reset_index()
    below_80 = country_ratios.loc[country_ratios["Sex"] > 0.60].loc[
        country_ratios["Sex"] <= 0.80]
    below_80 = below_80.reset_index()
    above_80 = country_ratios.loc[country_ratios["Sex"] > 0.80]
    above_80 = above_80.reset_index()
    worldmap_chart = World()
    worldmap_chart.title = 'Countrywise Particpation Percentages of Females'
    worldmap_chart.add("0%-20%", [
        'af', 'dz', 'au', 'ar', 'am', 'be', 'bj', 'bz', 'cz', 'bw', 'bn', 'cl',
        'dk', 'dj', 'eg', 'er', 'fi', 'gh', 'ht', 'in', 'ir', 'iq', 'sa', 'kw',
        'ly', 'lr', 'lb', 'lu', 'my', 'ma', 'mw', 'mc', 'mr', 'ni', 'om', 'pk',
        'py', 'ph', 'pt', 'pr', 'zw', 'de', 'rs', 'sh', 'sm', 'so', 'sd', 'ch',
        'sz', 'sy', 'tz', 'tg', 'tn', 'tr', 'ae', 'ug', 'uy', 'vn', 'ye', 'mk',
        'zm'
    ])
    worldmap_chart.add('20%-40%', [
        'al', 'ad', 'au', 'at', 'az', 'bi', 'bo', 'br', 'bh', 'bg', 'bf', 'cf',
        'kh', 'ca', 'cg', 'td', 'cm', 'cd', 'co', 'cr', 'hr', 'cu', 'cy', 'cz',
        'do', 'ec', 'sv', 'es', 'ee', 'et', 'ru', 'fr', 'de', 'ga', 'gm', 'gb',
        'gw', 'ge', 'gq', 'gr', 'gn', 'gu', 'gy', 'cn', 'hn', 'hu', 'id', 'ie',
        'is', 'il', 'it', 'jo', 'jp', 'kz', 'ke', 'kg', 'kr', 'la', 'lv', 'ls',
        'li', 'lt', 'md', 'mv', 'mx', 'mn', 'mk', 'ml', 'mt', 'me', 'mz', 'mu',
        'mm', 'na', 'nl', 'np', 'ng', 'ne', 'no', 'nz', 'pa', 'pe', 'ps', 'pg',
        'pl', 'ro', 'za', 'rw', 'sc', 'sg', 'sl', 'si', 'rs', 'lk', 'sd', 'st',
        'sr', 'sk', 'se', 'cz', 'th', 'tj', 'tw', 'ru', 'us', 'uz', 've', 'zw'
    ])
    worldmap_chart.add('40%-60%', [
        'ao', 'bt', 'by', 'cn', 'cv', 'jm', 'mg', 'kp', 'ru', 'tm', 'tl', 'ua',
        'vn'
    ])
    worldmap_chart.add('60%-80%', [])
    worldmap_chart.add('80%-100%', [])
    worldmap_chart.render_in_browser()
コード例 #2
0
class PWorldMap(object):
    '''
    classdocs
    '''
    def __init__(self, title):
        '''
        Constructor
        '''
        self.wmap = World()
        self.wmap.title = title

    def sample(self):
        self.wmap.add('F countries', ['fr', 'fi'])
        self.wmap.add('M countries', [
            'ma', 'mc', 'md', 'me', 'mg', 'mk', 'ml', 'mm', 'mn', 'mo', 'mr',
            'mt', 'mu', 'mv', 'mw', 'mx', 'my', 'mz'
        ])
        self.wmap.add('U countries', ['ua', 'ug', 'us', 'uy', 'uz'])
        self.wmap.add('North America', {
            'ca': 84949494949,
            'mx': 494794164,
            'us': 99794616
        })

    def render(self, filename=None):
        '''
        render the map
        see http://www.pygal.org/en/stable/documentation/output.html
        '''
        if filename is None:
            self.wmap.render_in_browser()
        else:
            if filename.endswith(".png"):
                self.wmap.render_to_png(filename)
            else:
                self.wmap.render_to_file(filename)
コード例 #3
0
#         valorConvertido += 1
#         print(valorConvertido)

# mapaMundi = World()
# mapaMundi.title = 'Norte, Central e Sul'
# mapaMundi.add('Norte',['ca','mx','us'])
# mapaMundi.add('Central',['ma', 'mc', 'md', 'me', 'mg','mk', 'ml', 'mm', 'mn', 'mo','mr', 'mt', 'mu', 'mv', 'mw'])
# mapaMundi.add('Sul',['ar','br','cl'])
# mapaMundi.render_in_browser()

# Plotando dados numéricos em um mapa-múndi

mapaMundi = World()
mapaMundi.title = 'Norte, Central e Sul'
mapaMundi.add('Norte', {'ca': 21, 'mx': 22, 'us': 23})
mapaMundi.add(
    'Central', {
        'ma': 42,
        'mc': 33,
        'md': 421,
        'me': 45,
        'mg': 31,
        'mk': 11,
        'ml': 48,
        'mm': 44,
        'mn': 76,
        'mo': 9
    })
mapaMundi.add('Sul', {'ar': 22, 'br': 11, 'cl': 34})
mapaMundi.render_in_browser()