Created
January 7, 2018 15:33
-
-
Save mcampbell/6c6073dcf2068b9e57cc12ada96f9917 to your computer and use it in GitHub Desktop.
Bokeh Bar Plot
This file contains 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
#!/usr/bin/env python3 | |
import sqlite3 | |
from bokeh.plotting import figure, output_file, show, save | |
from bokeh.models.tickers import FixedTicker, DaysTicker | |
from bokeh.models import HoverTool, PanTool, WheelZoomTool, BoxZoomTool, ResetTool | |
from bokeh.models import ColumnDataSource | |
def main(): | |
# output to static HTML file | |
output_file('lines.html') | |
dates = [1484870400000, 1484956800000, 1485043200000, 1485129600000, | |
1485216000000, 1485302400000, 1485388800000, 1485475200000, 1485561600000, | |
1485648000000, 1485734400000, 1485820800000, 1485907200000, 1485993600000, | |
1486080000000, 1486166400000, 1486252800000, 1486339200000, 1486425600000, | |
1486512000000, 1486598400000, 1486684800000, 1486771200000, 1486857600000, | |
1486944000000, 1487030400000, 1487116800000, 1487203200000, 1487289600000, | |
1487376000000, 1487462400000, 1487548800000, 1487635200000, 1487721600000, | |
1487808000000, 1487894400000, 1487980800000, 1488067200000, 1488153600000, | |
1488240000000, 1488326400000, 1488412800000, 1488499200000, 1488585600000, | |
1488672000000, 1488758400000, 1488844800000, 1488931200000, 1489017600000, | |
1489104000000, 1489190400000, 1489276800000, 1489363200000, 1489449600000, | |
1489536000000, 1489622400000, 1489708800000, 1489795200000, 1489881600000, | |
1489968000000, 1490054400000, 1490140800000, 1490227200000, 1490313600000, | |
1490400000000, 1490486400000, 1490572800000, 1490659200000, 1491004800000, | |
1491091200000, 1491177600000, 1491264000000, 1491350400000, 1491436800000, | |
1491523200000, 1491609600000, 1491696000000, 1491782400000, 1491868800000, | |
1491955200000, 1492041600000, 1492128000000, 1492214400000, 1492300800000, | |
1492387200000, 1492473600000, 1492560000000, 1492646400000, 1492732800000, | |
1492819200000, 1492905600000, 1492992000000, 1493078400000, 1493164800000, | |
1493251200000, 1493337600000, 1493424000000, 1493510400000, 1493596800000, | |
1493683200000, 1493769600000, 1493856000000, 1493942400000, 1494028800000, | |
1494115200000, 1494201600000, 1494288000000, 1494374400000, 1494460800000, | |
1494547200000, 1494633600000, 1494720000000, 1494806400000, 1494892800000, | |
1494979200000, 1495065600000, 1495152000000, 1495238400000, 1495324800000, | |
1495411200000, 1495497600000, 1495584000000, 1495670400000, 1495756800000, | |
1495843200000, 1495929600000, 1496016000000, 1496102400000, 1496188800000, | |
1496275200000, 1496361600000, 1496448000000, 1496534400000, 1496620800000, | |
1496707200000, 1496793600000, 1496880000000, 1496966400000, 1497052800000, | |
1497139200000, 1497225600000, 1497312000000, 1497398400000, 1497484800000, | |
1497571200000, 1497657600000, 1497744000000, 1497830400000, 1497916800000, | |
1498003200000, 1498089600000, 1498176000000, 1498262400000, 1498348800000, | |
1498435200000, 1498521600000, 1498608000000, 1498694400000, 1498780800000, | |
1498867200000, 1498953600000, 1499040000000, 1499126400000, 1499212800000, | |
1499299200000, 1499385600000, 1499472000000, 1499558400000, 1499644800000, | |
1499731200000, 1499817600000, 1499904000000, 1499990400000, 1500076800000, | |
1500163200000, 1500249600000, 1500336000000, 1500422400000, 1500508800000, | |
1500595200000, 1500681600000, 1500768000000, 1500854400000, 1500940800000, | |
1501027200000, 1501113600000, 1501200000000, 1501286400000, 1501372800000, | |
1501459200000, 1501545600000, 1501632000000, 1501718400000, 1501804800000, | |
1501891200000, 1501977600000, 1502064000000, 1502150400000, 1502236800000, | |
1502323200000, 1502409600000, 1502496000000, 1502582400000, 1502668800000, | |
1502755200000, 1502841600000, 1502928000000, 1503014400000, 1503100800000, | |
1503187200000, 1503273600000, 1503360000000, 1503446400000, 1503532800000, | |
1503619200000, 1503705600000, 1503792000000, 1503878400000, 1503964800000, | |
1504051200000, 1504137600000, 1504224000000, 1504310400000, 1504396800000, | |
1504483200000, 1504569600000, 1504656000000, 1504742400000, 1504828800000, | |
1504915200000, 1505001600000, 1505088000000, 1505174400000, 1505260800000, | |
1505347200000, 1505433600000, 1505520000000, 1505606400000, 1505692800000, | |
1505779200000, 1505865600000, 1505952000000, 1506038400000, 1506124800000, | |
1506211200000, 1506297600000, 1506384000000, 1506470400000, 1506556800000, | |
1506643200000, 1506729600000, 1506816000000, 1506902400000, 1506988800000, | |
1507075200000, 1507161600000, 1507248000000, 1507334400000, 1507420800000, | |
1507507200000, 1507593600000, 1507680000000, 1507766400000, 1507852800000, | |
1507939200000, 1508025600000, 1508112000000, 1508198400000, 1508284800000, | |
1508371200000, 1508457600000, 1508544000000, 1508630400000, 1508716800000, | |
1508803200000, 1508889600000, 1508976000000, 1509062400000, 1509148800000, | |
1509235200000, 1509321600000, 1509408000000, 1509494400000, 1509580800000, | |
1509667200000, 1509753600000, 1509840000000, 1509926400000, 1510012800000, | |
1510099200000, 1510185600000, 1510358400000, 1510444800000, 1510531200000, | |
1510617600000, 1510704000000, 1510790400000, 1511049600000, 1511136000000, | |
1511222400000, 1511308800000, 1511395200000, 1511568000000, 1511654400000, | |
1511740800000, 1511827200000, 1511913600000, 1512000000000, 1512086400000, | |
1512172800000, 1512259200000, 1512345600000, 1512432000000, 1512518400000, | |
1512604800000, 1512691200000, 1512777600000, 1512864000000, 1512950400000, | |
1513036800000, 1513123200000, 1513209600000, 1513296000000, 1513382400000, | |
1513468800000, 1513555200000, 1513641600000, 1513728000000, 1513814400000, | |
1513900800000, 1513987200000, 1514073600000, 1514160000000, 1514246400000, | |
1514332800000, 1514419200000, 1514505600000, 1514592000000, 1514678400000, | |
1514764800000, 1514851200000, 1514937600000, 1515024000000, 1515110400000, | |
1515196800000, 1515283200000] | |
populations = [3005, 2762, 3116, 3120, 2719, 3049, 3242, 3037, 4529, 4899, | |
3113, 4006, 3850, 3861, 3872, 4220, 4363, 3966, 3907, 3773, 3899, 3635, | |
4039, 4324, 3867, 3220, 3619, 3545, 3545, 3827, 4167, 3963, 3619, 3415, | |
3476, 3391, 3680, 3960, 3526, 3427, 3339, 3324, 3248, 3481, 4006, 3504, | |
3320, 3162, 2967, 3170, 3393, 3897, 3406, 3450, 3335, 3223, 3061, 3227, | |
3602, 3280, 3138, 3108, 2998, 2939, 3060, 3389, 3031, 2837, 2643, 2925, | |
2694, 2653, 1477, 2569, 2458, 2411, 2792, 2585, 2330, 2331, 2422, 2702, | |
2621, 2627, 2596, 2378, 2391, 2450, 2387, 2512, 2712, 2403, 2332, 2210, | |
2241, 2136, 2187, 2377, 2353, 2205, 2115, 2161, 2050, 1959, 2346, 2160, | |
2029, 1988, 2007, 1899, 1865, 2060, 1956, 1844, 1804, 1786, 1788, 1788, | |
2116, 1871, 1876, 1690, 1615, 1591, 1572, 1794, 1947, 1684, 1623, 1593, | |
1515, 1455, 1753, 1637, 1662, 1646, 1558, 1450, 1472, 1634, 1548, 1486, | |
1381, 1404, 1322, 1391, 1442, 1485, 1356, 1264, 1300, 758, 1266, 1425, | |
1371, 1351, 1253, 1209, 1178, 1159, 1307, 1416, 1334, 1281, 1181, 1144, | |
1165, 1325, 1310, 1268, 1204, 1133, 1125, 1118, 1295, 1191, 1184, 1128, | |
1006, 1029, 1053, 1216, 1119, 1122, 1081, 1075, 1005, 1030, 1124, 1057, | |
1050, 1068, 993, 953, 987, 1099, 1017, 1010, 989, 1136, 1132, 1146, 1264, | |
1049, 1055, 1004, 978, 1013, 1032, 1216, 1069, 1061, 976, 1006, 963, 1009, | |
1232, 1063, 1095, 1065, 1007, 1007, 1066, 1235, 1263, 1063, 1099, 1048, | |
1080, 1112, 1242, 1102, 448, 1059, 1069, 1090, 1068, 1220, 1162, 1143, | |
1091, 1081, 1083, 1124, 1200, 1133, 1115, 1108, 974, 1026, 1081, 1200, | |
1130, 1081, 1125, 1117, 1100, 1119, 1250, 1180, 1095, 1090, 1076, 1049, | |
1132, 1196, 1115, 1101, 1061, 1066, 1006, 1073, 1260, 1082, 1075, 1025, | |
1076, 997, 989, 1111, 997, 973, 1048, 959, 980, 1013, 1179, 1043, 1045, | |
1027, 1027, 1001, 1194, 1051, 1023, 983, 282, 1097, 1016, 978, 994, 963, | |
625, 1086, 1004, 1004, 966, 941, 894, 921, 1059, 967, 961, 954, 960, 859, | |
949, 1115, 948, 926, 908, 849, 829, 937, 1062, 962, 966, 886, 883, 887, | |
880, 543, 744, 849, 926, 959, 949, 1013, 740, 972, 1063, 1031, 1073, 973, | |
1148, 851] | |
source = ColumnDataSource(data=dict(x=dates, top=populations)) | |
p = figure(title="Max Population By Day", x_axis_type='datetime', | |
x_axis_label='Date', y_axis_label='Population', | |
plot_width=800, plot_height=600, | |
tools=["pan", "wheel_zoom", "box_zoom", "reset", "hover"]) | |
p.vbar(x='x', top='top', source=source, width=1.0, line_width=1.5, color='green') | |
save(p) | |
if __name__ == '__main__': | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
2 things I have not been able to figure out.