{"action":"opened","issue":{"url":"https://api.github.com/repos/kthouz/upwork/issues/1","labels_url":"https://api.github.com/repos/kthouz/upwork/issues/1/labels{/name}","comments_url":"https://api.github.com/repos/kthouz/upwork/issues/1/comments","events_url":"https://api.github.com/repos/kthouz/upwork/issues/1/events","html_url":"https://github.com/kthouz/upwork/issues/1","id":114429786,"number":1,"title":"Solution to Stackoverflow question","user":{"login":"onilton","id":725676,"avatar_url":"https://avatars.githubusercontent.com/u/725676?v=3","gravatar_id":"","url":"https://api.github.com/users/onilton","html_url":"https://github.com/onilton","followers_url":"https://api.github.com/users/onilton/followers","following_url":"https://api.github.com/users/onilton/following{/other_user}","gists_url":"https://api.github.com/users/onilton/gists{/gist_id}","starred_url":"https://api.github.com/users/onilton/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/onilton/subscriptions","organizations_url":"https://api.github.com/users/onilton/orgs","repos_url":"https://api.github.com/users/onilton/repos","events_url":"https://api.github.com/users/onilton/events{/privacy}","received_events_url":"https://api.github.com/users/onilton/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":0,"created_at":"2015-10-31T19:36:43Z","updated_at":"2015-10-31T19:36:43Z","closed_at":null,"body":"I think you deleted your stackoverflow question, I was about to answer it when you deleted it =/ . But here is the solution for your problem:\r\n\r\n```python\r\n#!/usr/bin/python2\r\nimport json\r\nfrom collections import OrderedDict\r\nfrom bokeh.plotting import figure, show, output_file, ColumnDataSource\r\nfrom bokeh.models import HoverTool\r\nimport csv\r\nimport math\r\nwith open('countries.json','r') as f:\r\n    geodata = json.load(f)\r\nf.close()\r\ngeodata_features = geodata['features']\r\ncountry_xs = []\r\ncountry_ys = []\r\ncountry_names = []\r\ncountry_num_users = []\r\ncountry_colors = []\r\ncolors = ['#ffb6c1','#db7093','#b03060','#c71585',\r\n          '#d02090','#ee82ee','#dda0dd','#da70d6',\r\n          '#ba55d3','#9932cc','#9400d3','#8a2be2',\r\n          '#a020f0','#9370db','#d8bfd8']\r\n\r\nuser_by_country_count = {}\r\n\r\nwith open('data.csv') as csvfile:\r\n    reader = csv.DictReader(csvfile)\r\n    for row in reader:\r\n        user_by_country_count[row['Country']] = row['Count']\r\n        print(row['Country'], row['Count'])\r\n\r\nfor aCountry in geodata_features:\r\n    cName = aCountry['properties']['name']\r\n    print cName\r\n    if cName in user_by_country_count.keys():\r\n        coords = aCountry['geometry']['coordinates'][0]\r\n        # Set all coordinates as a list with only two hierarchical levels\r\n        #if type(coords[0][0]) == list:\r\n        #    coords_len = len(coords)\r\n        #    tmp = coords[0]\r\n        #    for i in range(1,coords_len):\r\n        #        for j in coords[i]:\r\n        #            tmp+=coords[i][j]\r\n        #coords = tmp\r\n        country_xs.append(map(lambda x:x[0],coords))\r\n        country_ys.append(map(lambda x:x[1],coords))\r\n        country_names.append(cName)\r\n        num_users = user_by_country_count.get(cName)\r\n        country_num_users.append(num_users)\r\n        idx = min(int(math.log(float(num_users))), len(colors) - 1)\r\n        country_colors.append(colors[idx])\r\n\r\nsource = ColumnDataSource(\r\n    data = dict(\r\n        x=country_xs,\r\n        y=country_ys,\r\n        color=country_colors,\r\n        name=country_names,\r\n        users=country_num_users,\r\n    )\r\n)\r\noutput_file(\"global.html\", title=\"global.py example\")\r\nTOOLS=\"pan,wheel_zoom,box_zoom,reset,hover,save\"\r\np = figure(title=\"Upwork Users Location\", tools=TOOLS)\r\np.patches('x', 'y',\r\n    fill_color=country_colors, fill_alpha=0.7,\r\n    line_color=\"white\", line_width=0.5,\r\n    source=source)\r\nhover = p.select(dict(type=HoverTool))\r\nhover.point_policy = \"follow_mouse\"\r\nhover.tooltips = OrderedDict([\r\n    (\"Name\", \"@name\"),\r\n    (\"Number of Users\", \"@users\"),\r\n    (\"(Long, Lat)\", \"($x, $y)\"),\r\n])\r\nshow(p)\r\n```"}}