Last active
May 8, 2017 16:34
-
-
Save gauravpatt92/041518ce1073f68daac67aa7f500e639 to your computer and use it in GitHub Desktop.
bokeh plot for birthdays in each month.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import json | |
from collections import Counter | |
from bokeh.plotting import figure, show, output_file | |
with open("birthdays_1.json", "r") as f_r: | |
data = json.load(f_r) | |
l_month = [] | |
for i in data: | |
l_month.append(data[i].split("/")[1]) | |
c = Counter(l_month) #c is list containing the counts of birthdays in each month | |
m_sc = {} | |
m_sc["jan"]=c['01'] | |
m_sc["feb"]=c['02'] | |
m_sc["mar"]=c['03'] | |
m_sc["apr"]=c['04'] | |
m_sc["may"]=c['05'] | |
m_sc["jun"]=c['06'] | |
m_sc["jul"]=c['07'] | |
m_sc["aug"]=c['08'] | |
m_sc["sep"]=c['09'] | |
m_sc["oct"]=c['10'] | |
m_sc["nov"]=c['11'] | |
m_sc["dec"]=c['12'] | |
output_file("plot_bir_month.html") | |
x_categories = [] | |
x_now = [] | |
for j in m_sc.keys(): | |
x_categories.append(j) #to store all month | |
x_now.append(m_sc[j]) #to store count in every month | |
x = x_categories | |
y = x_now | |
p = figure(x_range=x_categories) | |
p.vbar(x=x, top=y, width=0.5) | |
show(p) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"Ben Franklin": "17/01/1776", | |
"James Watt": "30/01/1736", | |
"Albert Einstein": "14/03/1879", | |
"Neils Bohr": "07/10/1885", | |
"Clark Maxwell": "13/06/1831", | |
"Richard Fienmann": "11/05/1918" | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment