country_plot(by_country$data[[1]], by_country$model[[1]])
Created
January 11, 2017 20:43
-
-
Save hafen/36e6a21e5b9aaf9bb799094c396d8b2d to your computer and use it in GitHub Desktop.
gapminder_rbokeh
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
license: none | |
height: | |
scrolling: no | |
border: yes |
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
<!DOCTYPE html> | |
<html> | |
<head> | |
<script src='https://cdn.pydata.org/bokeh/release/bokeh-0.12.2.min.js'></script> | |
<link href='https://cdn.pydata.org/bokeh/release/bokeh-0.12.2.min.css' rel='stylesheet'> | |
</head> | |
<body> | |
<div class='bk-root' class='plotdiv' style=' width: 500px; height: 500px;'> | |
<div id='9f1a9fabb01a2ba13583950986159e56' class='plotdiv'></div> | |
<div> | |
<script type='text/javascript'> | |
Bokeh.$(function() { | |
var modelid = '863987a58206a7cc7f3834e680908918'; | |
var elementid = '9f1a9fabb01a2ba13583950986159e56'; | |
var docid = '9e7d819babaac711c28a17c6b7a22498'; | |
var docs_json = {"9e7d819babaac711c28a17c6b7a22498":{"version":"0.12.2","title":"Bokeh Figure","roots":{"root_ids":["863987a58206a7cc7f3834e680908918"],"references":[{"type":"Plot","id":"863987a58206a7cc7f3834e680908918","attributes":{"id":"863987a58206a7cc7f3834e680908918","plot_width":500,"plot_height":500,"sizing_mode":"scale_both","x_range":{"type":"Range1d","id":"203ea3117807f88b846a3a9f4333b0e0"},"y_range":{"type":"Range1d","id":"efcf609a47873ffa1ee78ee937acf9f0"},"left":[{"type":"LinearAxis","id":"1648ef3f30a433396d84399b0a2ab9b8"}],"below":[{"type":"LinearAxis","id":"ccc56ff2c366698aced8eb220381531f"}],"right":[],"above":[],"renderers":[{"type":"GlyphRenderer","id":"764591d636d651237235a6818e492ea6"},{"type":"GlyphRenderer","id":"85914b830b9d00d81609d293acff33fb"},{"type":"LinearAxis","id":"ccc56ff2c366698aced8eb220381531f"},{"type":"Grid","id":"3b068639ede1b7336022b871a8158c95"},{"type":"LinearAxis","id":"1648ef3f30a433396d84399b0a2ab9b8"},{"type":"Grid","id":"eee7eeea31f9504c6543b3a2233b3150"}],"extra_y_ranges":{},"extra_x_ranges":{},"tags":[],"min_border_left":4,"min_border_right":4,"min_border_top":4,"min_border_bottom":4,"lod_threshold":null,"toolbar_location":null,"toolbar":{"type":"Toolbar","id":"c0df35307c2b8bf3fd8b7640dc0466e9"},"tool_events":{"type":"ToolEvents","id":"e3eb150e798cf42671433044ec21fb8c"}},"subtype":"Figure"},{"type":"Toolbar","id":"c0df35307c2b8bf3fd8b7640dc0466e9","attributes":{"id":"c0df35307c2b8bf3fd8b7640dc0466e9","tags":[],"active_drag":"auto","active_scroll":"auto","active_tap":"auto","tools":[{"type":"HoverTool","id":"523bec7b828e592eefc15b243e908889"}],"logo":null}},{"type":"ToolEvents","id":"e3eb150e798cf42671433044ec21fb8c","attributes":{"id":"e3eb150e798cf42671433044ec21fb8c","tags":[]},"geometries":[]},{"type":"HoverTool","id":"523bec7b828e592eefc15b243e908889","attributes":{"id":"523bec7b828e592eefc15b243e908889","tags":[],"plot":{"type":"Plot","id":"863987a58206a7cc7f3834e680908918","subtype":"Figure"},"renderers":[{"type":"GlyphRenderer","id":"764591d636d651237235a6818e492ea6"}],"names":[],"anchor":"center","attachment":"horizontal","line_policy":"prev","mode":"mouse","point_policy":"snap_to_data","tooltips":[["year","@hover_col_1"],["lifeExp","@hover_col_2"],["pop","@hover_col_3"],["gdpPercap","@hover_col_4"]]}},{"type":"ColumnDataSource","id":"7e88a012b04f6cfca2c151f5703bc7e7","attributes":{"id":"7e88a012b04f6cfca2c151f5703bc7e7","tags":[],"column_names":["x","y","hover_col_1","hover_col_2","hover_col_3","hover_col_4"],"selected":[],"data":{"x":[1952,1957,1962,1967,1972,1977,1982,1987,1992,1997,2002,2007],"y":[28.801,30.332,31.997,34.02,36.088,38.438,39.854,40.822,41.674,41.763,42.129,43.828],"hover_col_1":["1952","1957","1962","1967","1972","1977","1982","1987","1992","1997","2002","2007"],"hover_col_2":["28.801","30.332","31.997","34.020","36.088","38.438","39.854","40.822","41.674","41.763","42.129","43.828"],"hover_col_3":[" 8425333"," 9240934","10267083","11537966","13079460","14880372","12881816","13867957","16317921","22227415","25268405","31889923"],"hover_col_4":["779.4453","820.8530","853.1007","836.1971","739.9811","786.1134","978.0114","852.3959","649.3414","635.3414","726.7341","974.5803"]}}},{"type":"Circle","id":"36ff6b892cb6c0d13491a6b7cbba4f3b","attributes":{"id":"36ff6b892cb6c0d13491a6b7cbba4f3b","tags":[],"size":{"units":"screen","value":10},"visible":true,"line_color":{"units":"data","value":"#1F77B4"},"fill_color":{"units":"data","value":"#1F77B4"},"line_alpha":{"units":"data","value":1},"fill_alpha":{"units":"data","value":0.5},"x":{"units":"data","field":"x"},"y":{"units":"data","field":"y"}}},{"type":"Circle","id":"824b8358257b6dfed4460a5cb4fca3b0","attributes":{"id":"824b8358257b6dfed4460a5cb4fca3b0","tags":[],"size":{"units":"screen","value":10},"visible":true,"line_color":{"units":"data","value":"#e1e1e1"},"fill_color":{"units":"data","value":"#e1e1e1"},"line_alpha":{"units":"data","value":1},"fill_alpha":{"units":"data","value":0.5},"x":{"units":"data","field":"x"},"y":{"units":"data","field":"y"}}},{"type":"Circle","id":"a68524fca4cfac33c72020833000a631","attributes":{"id":"a68524fca4cfac33c72020833000a631","tags":[],"size":{"units":"screen","value":10},"visible":true,"line_color":{"units":"data","value":"#1F77B4"},"fill_color":{"units":"data","value":"#1F77B4"},"line_alpha":{"units":"data","value":1},"fill_alpha":{"units":"data","value":1},"x":{"units":"data","field":"x"},"y":{"units":"data","field":"y"}}},{"type":"GlyphRenderer","id":"764591d636d651237235a6818e492ea6","attributes":{"id":"764591d636d651237235a6818e492ea6","tags":[],"selection_glyph":null,"nonselection_glyph":{"type":"Circle","id":"824b8358257b6dfed4460a5cb4fca3b0"},"hover_glyph":{"type":"Circle","id":"a68524fca4cfac33c72020833000a631"},"name":null,"data_source":{"type":"ColumnDataSource","id":"7e88a012b04f6cfca2c151f5703bc7e7"},"glyph":{"type":"Circle","id":"36ff6b892cb6c0d13491a6b7cbba4f3b"}}},{"type":"ColumnDataSource","id":"ae16914592e9331e7818323211c830bf","attributes":{"id":"ae16914592e9331e7818323211c830bf","tags":[],"column_names":["x0","y0","x1","y1"],"selected":[],"data":{"x0":[0],"y0":[-507.534271561773],"x1":[1],"y1":[-507.258942890444]}}},{"type":"Segment","id":"14afc8de4ddb9fbcf9242f7937ba9cf3","attributes":{"id":"14afc8de4ddb9fbcf9242f7937ba9cf3","tags":[],"visible":true,"line_color":{"units":"data","value":"black"},"line_width":{"units":"data","value":1},"x0":{"units":"data","field":"x0"},"y0":{"units":"data","field":"y0"},"x1":{"units":"data","field":"x1"},"y1":{"units":"data","field":"y1"}}},{"type":"Segment","id":"13d387bc2f08f2cd2ac77169c0e59705","attributes":{"id":"13d387bc2f08f2cd2ac77169c0e59705","tags":[],"visible":true,"line_color":{"units":"data","value":"#e1e1e1"},"line_width":{"units":"data","value":1},"x0":{"units":"data","field":"x0"},"y0":{"units":"data","field":"y0"},"x1":{"units":"data","field":"x1"},"y1":{"units":"data","field":"y1"}}},{"type":"Segment","id":"e2defca603ee37e08b98b34119c5e451","attributes":{"id":"e2defca603ee37e08b98b34119c5e451","tags":[],"visible":true,"line_color":{"units":"data","value":"black"},"line_width":{"units":"data","value":1},"x0":{"units":"data","field":"x0"},"y0":{"units":"data","field":"y0"},"x1":{"units":"data","field":"x1"},"y1":{"units":"data","field":"y1"}}},{"type":"GlyphRenderer","id":"85914b830b9d00d81609d293acff33fb","attributes":{"id":"85914b830b9d00d81609d293acff33fb","tags":[],"selection_glyph":null,"nonselection_glyph":{"type":"Segment","id":"13d387bc2f08f2cd2ac77169c0e59705"},"hover_glyph":{"type":"Segment","id":"e2defca603ee37e08b98b34119c5e451"},"name":null,"data_source":{"type":"ColumnDataSource","id":"c88a5f37a9b96fbd2c224c147475ede3"},"glyph":{"type":"Segment","id":"14afc8de4ddb9fbcf9242f7937ba9cf3"}}},{"type":"Range1d","id":"203ea3117807f88b846a3a9f4333b0e0","attributes":{"id":"203ea3117807f88b846a3a9f4333b0e0","tags":[],"start":1948,"end":2011}},{"type":"Range1d","id":"efcf609a47873ffa1ee78ee937acf9f0","attributes":{"id":"efcf609a47873ffa1ee78ee937acf9f0","tags":[],"start":10,"end":95}},{"type":"LinearAxis","id":"ccc56ff2c366698aced8eb220381531f","attributes":{"id":"ccc56ff2c366698aced8eb220381531f","tags":[],"plot":{"type":"Plot","id":"863987a58206a7cc7f3834e680908918","subtype":"Figure"},"axis_label":"year","formatter":{"type":"BasicTickFormatter","id":"97d748c867ded24d22ffafc132670256"},"ticker":{"type":"BasicTicker","id":"a17efc36459a349235d068f6ca58d12d"},"visible":true,"axis_label_text_font_size":"12pt"}},{"type":"BasicTickFormatter","id":"97d748c867ded24d22ffafc132670256","attributes":{"id":"97d748c867ded24d22ffafc132670256","tags":[]}},{"type":"BasicTicker","id":"a17efc36459a349235d068f6ca58d12d","attributes":{"id":"a17efc36459a349235d068f6ca58d12d","tags":[],"num_minor_ticks":5}},{"type":"Grid","id":"3b068639ede1b7336022b871a8158c95","attributes":{"id":"3b068639ede1b7336022b871a8158c95","tags":[],"dimension":0,"plot":{"type":"Plot","id":"863987a58206a7cc7f3834e680908918","subtype":"Figure"},"ticker":{"type":"BasicTicker","id":"a17efc36459a349235d068f6ca58d12d"}}},{"type":"LinearAxis","id":"1648ef3f30a433396d84399b0a2ab9b8","attributes":{"id":"1648ef3f30a433396d84399b0a2ab9b8","tags":[],"plot":{"type":"Plot","id":"863987a58206a7cc7f3834e680908918","subtype":"Figure"},"axis_label":"lifeExp","formatter":{"type":"BasicTickFormatter","id":"adb5e667f3a79d358022025def413be9"},"ticker":{"type":"BasicTicker","id":"49b5f39af5b7ea6106bb44b203116115"},"visible":true,"axis_label_text_font_size":"12pt"}},{"type":"BasicTickFormatter","id":"adb5e667f3a79d358022025def413be9","attributes":{"id":"adb5e667f3a79d358022025def413be9","tags":[]}},{"type":"BasicTicker","id":"49b5f39af5b7ea6106bb44b203116115","attributes":{"id":"49b5f39af5b7ea6106bb44b203116115","tags":[],"num_minor_ticks":5}},{"type":"Grid","id":"eee7eeea31f9504c6543b3a2233b3150","attributes":{"id":"eee7eeea31f9504c6543b3a2233b3150","tags":[],"dimension":1,"plot":{"type":"Plot","id":"863987a58206a7cc7f3834e680908918","subtype":"Figure"},"ticker":{"type":"BasicTicker","id":"49b5f39af5b7ea6106bb44b203116115"}}},{"type":"ColumnDataSource","id":"c88a5f37a9b96fbd2c224c147475ede3","attributes":{"id":"c88a5f37a9b96fbd2c224c147475ede3","tags":[],"column_names":["x0","y0","x1","y1"],"selected":[],"data":{"x0":[1948],"y0":[28.805980186495],"x1":[2011],"y1":[46.1516864802019]}}}]}}}; | |
var refkey = Object.keys(docs_json)[0] | |
var refs = docs_json[refkey].roots.references | |
function traverseObject(obj) { | |
for (var key in obj) { | |
if (obj[key].constructor === Object) { | |
traverseObject(obj[key]); | |
} else if (obj[key].constructor === Array) { | |
for (var i = 0; i < obj[key].length; i++) { | |
if (obj[key][i] === null) | |
obj[key][i] = NaN; | |
}; | |
} | |
}; | |
} | |
for (var i = 0; i < refs.length; i++) { | |
if (refs[i].type === 'ColumnDataSource') | |
traverseObject(refs[i].attributes.data); | |
}; | |
var render_items = [{ | |
'docid': docid, | |
'elementid': elementid, | |
'modelid': modelid | |
}]; | |
Bokeh.set_log_level('info'); | |
Bokeh.embed.embed_items(docs_json, render_items); | |
}); | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment