rbokeh

A Simple, Flexible, Declarative Framework for Interactive Graphics

Follow along live: http://bit.ly/rbokeh1v

View at your own pace: http://bit.ly/rbokeh1

What is rbokeh?

  • An R interface to the Bokeh library
  • Bokeh:
  • rbokeh goals:
    • General purpose web-based visualization system for ad-hoc statistical graphics
    • R-like interface
    • Simple transient interactivity for free or with very little effort (zoom / pan / tooltips / etc.)
    • Put more complex interactivity within reach

bokeh

Interface

Python

rbokeh

R

Bokeh.jl

Julia

bokeh-scala

Scala

JSON spec

{
  "x": {
    "elementid": "8b6c0abd6e5affc74709b702ba9f63dd",
    "modeltype": "Plot",
    "modelid": "2bd6591010f5f4263e7539d8abd41161",
    "docid": "49d325c6b0dbafed8d9edba171e29f84",
    "docs_json": {
      "49d325c6b0dbafed8d9edba171e29f84": {
        "version": "0.11.1",
        "title": "Bokeh Figure",
        "roots": {
          "root_ids": [
            "2bd6591010f5f4263e7539d8abd41161"
          ],
          "references": [
            {
              "type": "Plot",
              "id": "2bd6591010f5f4263e7539d8abd41161",
              "attributes": {
                "title": null,
                "id": "2bd6591010f5f4263e7539d8abd41161",
                "plot_width": 590,
                "plot_height": 354,
                "x_range": {
                  "type": "Range1d",
                  "id": "855b06b5143027e4d28fbd56f354cd1a"
                },
                "y_range": {
                  "type": "Range1d",
                  "id": "38a564fc3ae79fcae972c4aedce6cc73"
                },
                "left": [
                  {
                    "type": "LinearAxis",
                    "id": "e96acc27b60637e37f71f0992e6a1759"
                  }
                ],
                "below": [
                  {
                    "type": "LinearAxis",
                    "id": "c777f597c0492c638fc6ca3c9aa79eb7"
                  }
                ],
                "right": [],
                "above": [],
                "renderers": [
                  {
                    "type": "BoxAnnotation",
                    "id": "fc45456a9b894e1e3ecc3d34eb4b6d70"
                  },
                  {
                    "type": "GlyphRenderer",
                    "id": "65f9ebc1196641edb5ef536629f7446a"
                  },
                  {
                    "type": "GlyphRenderer",
                    "id": "c219999a52cbabb369b59cf49ad418b4"
                  },
                  {
                    "type": "LinearAxis",
                    "id": "c777f597c0492c638fc6ca3c9aa79eb7"
                  },
                  {
                    "type": "Grid",
                    "id": "37bd3b4c846f3688f2b5ff6f22ba2a29"
                  },
                  {
                    "type": "LinearAxis",
                    "id": "e96acc27b60637e37f71f0992e6a1759"
                  },
                  {
                    "type": "Grid",
                    "id": "ccbad37d6b0181b634abd78597617c0c"
                  }
                ],
                "tools": [
                  {
                    "type": "PanTool",
                    "id": "07ee5fa3fd44713bd31dc48131f6204e"
                  },
                  {
                    "type": "WheelZoomTool",
                    "id": "8801a673fe17e4a711b6276141762985"
                  },
                  {
                    "type": "BoxZoomTool",
                    "id": "1ab4e4fab27dc5b57f8f4b4e1526fb4f"
                  },
                  {
                    "type": "ResizeTool",
                    "id": "cafcf2b39570844605261c20579a3a0c"
                  },
                  {
                    "type": "ResetTool",
                    "id": "2b07b240860bb98dcac9fdccfd6821c7"
                  },
                  {
                    "type": "PreviewSaveTool",
                    "id": "02391b5dc908cd7a12a1b92c1c9053ac"
                  },
                  {
                    "type": "HelpTool",
                    "id": "9380370627015195ffa419cec085a730"
                  }
                ],
                "tool_events": {
                  "type": "ToolEvents",
                  "id": "88bac4bbcf4de01cb305797122a931ea"
                },
                "extra_y_ranges": {},
                "extra_x_ranges": {},
                "tags": [],
                "doc": null,
                "min_border_left": 4,
                "min_border_right": 4,
                "min_border_top": 4,
                "min_border_bottom": 4,
                "lod_threshold": null
              },
              "subtype": "Figure"
            },
            {
              "type": "PanTool",
              "id": "07ee5fa3fd44713bd31dc48131f6204e",
              "attributes": {
                "id": "07ee5fa3fd44713bd31dc48131f6204e",
                "tags": [],
                "doc": null,
                "plot": {
                  "type": "Plot",
                  "id": "2bd6591010f5f4263e7539d8abd41161",
                  "subtype": "Figure"
                },
                "dimensions": [
                  "width",
                  "height"
                ]
              }
            },
            {
              "type": "ToolEvents",
              "id": "88bac4bbcf4de01cb305797122a931ea",
              "attributes": {
                "id": "88bac4bbcf4de01cb305797122a931ea",
                "tags": [],
                "doc": null
              },
              "geometries": []
            },
            {
              "type": "WheelZoomTool",
              "id": "8801a673fe17e4a711b6276141762985",
              "attributes": {
                "id": "8801a673fe17e4a711b6276141762985",
                "tags": [],
                "doc": null,
                "plot": {
                  "type": "Plot",
                  "id": "2bd6591010f5f4263e7539d8abd41161",
                  "subtype": "Figure"
                },
                "dimensions": [
                  "width",
                  "height"
                ]
              }
            },
            {
              "type": "BoxAnnotation",
              "id": "fc45456a9b894e1e3ecc3d34eb4b6d70",
              "attributes": {
                "id": "fc45456a9b894e1e3ecc3d34eb4b6d70",
                "tags": [],
                "doc": null,
                "line_color": {
                  "units": "data",
                  "value": "black"
                },
                "line_alpha": {
                  "units": "data",
                  "value": 1
                },
                "fill_color": {
                  "units": "data",
                  "value": "lightgrey"
                },
                "fill_alpha": {
                  "units": "data",
                  "value": 0.5
                },
                "line_dash": [
                  4,
                  4
                ],
                "line_width": {
                  "units": "data",
                  "value": 2
                },
                "level": "overlay",
                "top_units": "screen",
                "bottom_units": "screen",
                "left_units": "screen",
                "right_units": "screen",
                "render_mode": "css"
              }
            },
            {
              "type": "BoxZoomTool",
              "id": "1ab4e4fab27dc5b57f8f4b4e1526fb4f",
              "attributes": {
                "id": "1ab4e4fab27dc5b57f8f4b4e1526fb4f",
                "tags": [],
                "doc": null,
                "plot": {
                  "type": "Plot",
                  "id": "2bd6591010f5f4263e7539d8abd41161",
                  "subtype": "Figure"
                },
                "overlay": {
                  "type": "BoxAnnotation",
                  "id": "fc45456a9b894e1e3ecc3d34eb4b6d70"
                }
              }
            },
            {
              "type": "ResizeTool",
              "id": "cafcf2b39570844605261c20579a3a0c",
              "attributes": {
                "id": "cafcf2b39570844605261c20579a3a0c",
                "tags": [],
                "doc": null,
                "plot": {
                  "type": "Plot",
                  "id": "2bd6591010f5f4263e7539d8abd41161",
                  "subtype": "Figure"
                }
              }
            },
            {
              "type": "ResetTool",
              "id": "2b07b240860bb98dcac9fdccfd6821c7",
              "attributes": {
                "id": "2b07b240860bb98dcac9fdccfd6821c7",
                "tags": [],
                "doc": null,
                "plot": {
                  "type": "Plot",
                  "id": "2bd6591010f5f4263e7539d8abd41161",
                  "subtype": "Figure"
                }
              }
            },
            {
              "type": "PreviewSaveTool",
              "id": "02391b5dc908cd7a12a1b92c1c9053ac",
              "attributes": {
                "id": "02391b5dc908cd7a12a1b92c1c9053ac",
                "tags": [],
                "doc": null,
                "plot": {
                  "type": "Plot",
                  "id": "2bd6591010f5f4263e7539d8abd41161",
                  "subtype": "Figure"
                }
              }
            },
            {
              "type": "HelpTool",
              "id": "9380370627015195ffa419cec085a730",
              "attributes": {
                "id": "9380370627015195ffa419cec085a730",
                "tags": [],
                "doc": null,
                "plot": {
                  "type": "Plot",
                  "id": "2bd6591010f5f4263e7539d8abd41161",
                  "subtype": "Figure"
                },
                "redirect": [
                  "http://hafen.github.io/rbokeh"
                ],
                "help_tooltip": [
                  "Click to learn more about rbokeh."
                ]
              }
            },
            {
              "type": "ColumnDataSource",
              "id": "dee55ef8ac74b72da4272b76619d8f0d",
              "attributes": {
                "id": "dee55ef8ac74b72da4272b76619d8f0d",
                "tags": [],
                "doc": null,
                "column_names": [
                  "left",
                  "right",
                  "top",
                  "bottom"
                ],
                "selected": [],
                "discrete_ranges": {},
                "cont_ranges": {},
                "data": {
                  "left": [
                    1.6,
                    1.7,
                    1.8,
                    1.9,
                    2,
                    2.1,
                    2.2,
                    2.3,
                    2.4,
                    2.5,
                    2.6,
                    2.7,
                    2.8,
                    2.9,
                    3,
                    3.1,
                    3.2,
                    3.3,
                    3.4,
                    3.5,
                    3.6,
                    3.7,
                    3.8,
                    3.9,
                    4,
                    4.1,
                    4.2,
                    4.3,
                    4.4,
                    4.5,
                    4.6,
                    4.7,
                    4.8,
                    4.9,
                    5
                  ],
                  "right": [
                    1.7,
                    1.8,
                    1.9,
                    2,
                    2.1,
                    2.2,
                    2.3,
                    2.4,
                    2.5,
                    2.6,
                    2.7,
                    2.8,
                    2.9,
                    3,
                    3.1,
                    3.2,
                    3.3,
                    3.4,
                    3.5,
                    3.6,
                    3.7,
                    3.8,
                    3.9,
                    4,
                    4.1,
                    4.2,
                    4.3,
                    4.4,
                    4.5,
                    4.6,
                    4.7,
                    4.8,
                    4.9,
                    5,
                    5.1
                  ],
                  "top": [
                    0.110294117647059,
                    0.477941176470589,
                    0.88235294117647,
                    0.551470588235295,
                    0.404411764705882,
                    0.294117647058823,
                    0.294117647058823,
                    0.25735294117647,
                    0.110294117647059,
                    0,
                    0.0735294117647061,
                    0.0367647058823529,
                    0.0735294117647058,
                    0,
                    0.0367647058823529,
                    0,
                    0,
                    0.147058823529412,
                    0.147058823529412,
                    0.220588235294117,
                    0.0367647058823529,
                    0.183823529411765,
                    0.330882352941178,
                    0.47794117647059,
                    0.441176470588233,
                    0.514705882352938,
                    0.47794117647059,
                    0.588235294117649,
                    0.735294117647061,
                    0.661764705882349,
                    0.477941176470586,
                    0.404411764705884,
                    0.294117647058825,
                    0.147058823529411,
                    0.110294117647059
                  ],
                  "bottom": [
                    0,
                    0,
                    0,
                    0,
                    0,
                    0,
                    0,
                    0,
                    0,
                    0,
                    0,
                    0,
                    0,
                    0,
                    0,
                    0,
                    0,
                    0,
                    0,
                    0,
                    0,
                    0,
                    0,
                    0,
                    0,
                    0,
                    0,
                    0,
                    0,
                    0,
                    0,
                    0,
                    0,
                    0,
                    0
                  ]
                }
              }
            },
            {
              "type": "Quad",
              "id": "723ead80aef18191e6582f5beadbfbb3",
              "attributes": {
                "id": "723ead80aef18191e6582f5beadbfbb3",
                "tags": [],
                "doc": null,
                "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
                },
                "left": {
                  "units": "data",
                  "field": "left"
                },
                "right": {
                  "units": "data",
                  "field": "right"
                },
                "top": {
                  "units": "data",
                  "field": "top"
                },
                "bottom": {
                  "units": "data",
                  "field": "bottom"
                }
              }
            },
            {
              "type": "Quad",
              "id": "4bbbcf442697a53109d3b2f53c963ed4",
              "attributes": {
                "id": "4bbbcf442697a53109d3b2f53c963ed4",
                "tags": [],
                "doc": null,
                "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
                },
                "left": {
                  "units": "data",
                  "field": "left"
                },
                "right": {
                  "units": "data",
                  "field": "right"
                },
                "top": {
                  "units": "data",
                  "field": "top"
                },
                "bottom": {
                  "units": "data",
                  "field": "bottom"
                }
              }
            },
            {
              "type": "Quad",
              "id": "014444b3b50e318c84e81d75da457c2f",
              "attributes": {
                "id": "014444b3b50e318c84e81d75da457c2f",
                "tags": [],
                "doc": null,
                "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
                },
                "left": {
                  "units": "data",
                  "field": "left"
                },
                "right": {
                  "units": "data",
                  "field": "right"
                },
                "top": {
                  "units": "data",
                  "field": "top"
                },
                "bottom": {
                  "units": "data",
                  "field": "bottom"
                }
              }
            },
            {
              "type": "GlyphRenderer",
              "id": "65f9ebc1196641edb5ef536629f7446a",
              "attributes": {
                "id": "65f9ebc1196641edb5ef536629f7446a",
                "tags": [],
                "doc": null,
                "selection_glyph": null,
                "nonselection_glyph": {
                  "type": "Quad",
                  "id": "4bbbcf442697a53109d3b2f53c963ed4"
                },
                "hover_glyph": {
                  "type": "Quad",
                  "id": "014444b3b50e318c84e81d75da457c2f"
                },
                "server_data_source": null,
                "name": null,
                "data_source": {
                  "type": "ColumnDataSource",
                  "id": "dee55ef8ac74b72da4272b76619d8f0d"
                },
                "glyph": {
                  "type": "Quad",
                  "id": "723ead80aef18191e6582f5beadbfbb3"
                }
              }
            },
            {
              "type": "ColumnDataSource",
              "id": "b5c25518231f9d947ed8ea93bdc807a9",
              "attributes": {
                "id": "b5c25518231f9d947ed8ea93bdc807a9",
                "tags": [],
                "doc": null,
                "column_names": [
                  "x",
                  "y"
                ],
                "selected": [],
                "discrete_ranges": {},
                "cont_ranges": {},
                "data": {
                  "x": [
                    0.59566889660817,
                    0.606449057482502,
                    0.617229218356834,
                    0.628009379231166,
                    0.638789540105498,
                    0.64956970097983,
                    0.660349861854162,
                    0.671130022728494,
                    0.681910183602826,
                    0.692690344477158,
                    0.70347050535149,
                    0.714250666225822,
                    0.725030827100154,
                    0.735810987974486,
                    0.746591148848818,
                    0.75737130972315,
                    0.768151470597482,
                    0.778931631471814,
                    0.789711792346147,
                    0.800491953220479,
                    0.81127211409481,
                    0.822052274969143,
                    0.832832435843475,
                    0.843612596717807,
                    0.854392757592139,
                    0.865172918466471,
                    0.875953079340803,
                    0.886733240215135,
                    0.897513401089467,
                    0.908293561963799,
                    0.919073722838131,
                    0.929853883712463,
                    0.940634044586795,
                    0.951414205461127,
                    0.962194366335459,
                    0.972974527209791,
                    0.983754688084123,
                    0.994534848958455,
                    1.00531500983279,
                    1.01609517070712,
                    1.02687533158145,
                    1.03765549245578,
                    1.04843565333011,
                    1.05921581420445,
                    1.06999597507878,
                    1.08077613595311,
                    1.09155629682744,
                    1.10233645770177,
                    1.11311661857611,
                    1.12389677945044,
                    1.13467694032477,
                    1.1454571011991,
                    1.15623726207343,
                    1.16701742294777,
                    1.1777975838221,
                    1.18857774469643,
                    1.19935790557076,
                    1.2101380664451,
                    1.22091822731943,
                    1.23169838819376,
                    1.24247854906809,
                    1.25325870994242,
                    1.26403887081676,
                    1.27481903169109,
                    1.28559919256542,
                    1.29637935343975,
                    1.30715951431408,
                    1.31793967518842,
                    1.32871983606275,
                    1.33949999693708,
                    1.35028015781141,
                    1.36106031868574,
                    1.37184047956008,
                    1.38262064043441,
                    1.39340080130874,
                    1.40418096218307,
                    1.4149611230574,
                    1.42574128393174,
                    1.43652144480607,
                    1.4473016056804,
                    1.45808176655473,
                    1.46886192742906,
                    1.4796420883034,
                    1.49042224917773,
                    1.50120241005206,
                    1.51198257092639,
                    1.52276273180072,
                    1.53354289267506,
                    1.54432305354939,
                    1.55510321442372,
                    1.56588337529805,
                    1.57666353617238,
                    1.58744369704672,
                    1.59822385792105,
                    1.60900401879538,
                    1.61978417966971,
                    1.63056434054404,
                    1.64134450141838,
                    1.65212466229271,
                    1.66290482316704,
                    1.67368498404137,
                    1.6844651449157,
                    1.69524530579004,
                    1.70602546666437,
                    1.7168056275387,
                    1.72758578841303,
                    1.73836594928736,
                    1.7491461101617,
                    1.75992627103603,
                    1.77070643191036,
                    1.78148659278469,
                    1.79226675365902,
                    1.80304691453336,
                    1.81382707540769,
                    1.82460723628202,
                    1.83538739715635,
                    1.84616755803068,
                    1.85694771890502,
                    1.86772787977935,
                    1.87850804065368,
                    1.88928820152801,
                    1.90006836240234,
                    1.91084852327668,
                    1.92162868415101,
                    1.93240884502534,
                    1.94318900589967,
                    1.953969166774,
                    1.96474932764834,
                    1.97552948852267,
                    1.986309649397,
                    1.99708981027133,
                    2.00786997114566,
                    2.01865013202,
                    2.02943029289433,
                    2.04021045376866,
                    2.05099061464299,
                    2.06177077551732,
                    2.07255093639166,
                    2.08333109726599,
                    2.09411125814032,
                    2.10489141901465,
                    2.11567157988898,
                    2.12645174076332,
                    2.13723190163765,
                    2.14801206251198,
                    2.15879222338631,
                    2.16957238426064,
                    2.18035254513498,
                    2.19113270600931,
                    2.20191286688364,
                    2.21269302775797,
                    2.2234731886323,
                    2.23425334950664,
                    2.24503351038097,
                    2.2558136712553,
                    2.26659383212963,
                    2.27737399300396,
                    2.2881541538783,
                    2.29893431475263,
                    2.30971447562696,
                    2.32049463650129,
                    2.33127479737562,
                    2.34205495824996,
                    2.35283511912429,
                    2.36361527999862,
                    2.37439544087295,
                    2.38517560174728,
                    2.39595576262162,
                    2.40673592349595,
                    2.41751608437028,
                    2.42829624524461,
                    2.43907640611894,
                    2.44985656699328,
                    2.46063672786761,
                    2.47141688874194,
                    2.48219704961627,
                    2.49297721049061,
                    2.50375737136494,
                    2.51453753223927,
                    2.5253176931136,
                    2.53609785398793,
                    2.54687801486226,
                    2.5576581757366,
                    2.56843833661093,
                    2.57921849748526,
                    2.58999865835959,
                    2.60077881923393,
                    2.61155898010826,
                    2.62233914098259,
                    2.63311930185692,
                    2.64389946273125,
                    2.65467962360559,
                    2.66545978447992,
                    2.67623994535425,
                    2.68702010622858,
                    2.69780026710291,
                    2.70858042797725,
                    2.71936058885158,
                    2.73014074972591,
                    2.74092091060024,
                    2.75170107147457,
                    2.76248123234891,
                    2.77326139322324,
                    2.78404155409757,
                    2.7948217149719,
                    2.80560187584623,
                    2.81638203672057,
                    2.8271621975949,
                    2.83794235846923,
                    2.84872251934356,
                    2.85950268021789,
                    2.87028284109223,
                    2.88106300196656,
                    2.89184316284089,
                    2.90262332371522,
                    2.91340348458955,
                    2.92418364546389,
                    2.93496380633822,
                    2.94574396721255,
                    2.95652412808688,
                    2.96730428896121,
                    2.97808444983555,
                    2.98886461070988,
                    2.99964477158421,
                    3.01042493245854,
                    3.02120509333287,
                    3.03198525420721,
                    3.04276541508154,
                    3.05354557595587,
                    3.0643257368302,
                    3.07510589770453,
                    3.08588605857887,
                    3.0966662194532,
                    3.10744638032753,
                    3.11822654120186,
                    3.12900670207619,
                    3.13978686295053,
                    3.15056702382486,
                    3.16134718469919,
                    3.17212734557352,
                    3.18290750644785,
                    3.19368766732219,
                    3.20446782819652,
                    3.21524798907085,
                    3.22602814994518,
                    3.23680831081951,
                    3.24758847169385,
                    3.25836863256818,
                    3.26914879344251,
                    3.27992895431684,
                    3.29070911519117,
                    3.30148927606551,
                    3.31226943693984,
                    3.32304959781417,
                    3.3338297586885,
                    3.34460991956283,
                    3.35539008043717,
                    3.3661702413115,
                    3.37695040218583,
                    3.38773056306016,
                    3.39851072393449,
                    3.40929088480883,
                    3.42007104568316,
                    3.43085120655749,
                    3.44163136743182,
                    3.45241152830615,
                    3.46319168918049,
                    3.47397185005482,
                    3.48475201092915,
                    3.49553217180348,
                    3.50631233267781,
                    3.51709249355215,
                    3.52787265442648,
                    3.53865281530081,
                    3.54943297617514,
                    3.56021313704947,
                    3.57099329792381,
                    3.58177345879814,
                    3.59255361967247,
                    3.6033337805468,
                    3.61411394142113,
                    3.62489410229547,
                    3.6356742631698,
                    3.64645442404413,
                    3.65723458491846,
                    3.66801474579279,
                    3.67879490666713,
                    3.68957506754146,
                    3.70035522841579,
                    3.71113538929012,
                    3.72191555016445,
                    3.73269571103879,
                    3.74347587191312,
                    3.75425603278745,
                    3.76503619366178,
                    3.77581635453611,
                    3.78659651541045,
                    3.79737667628478,
                    3.80815683715911,
                    3.81893699803344,
                    3.82971715890777,
                    3.84049731978211,
                    3.85127748065644,
                    3.86205764153077,
                    3.8728378024051,
                    3.88361796327943,
                    3.89439812415377,
                    3.9051782850281,
                    3.91595844590243,
                    3.92673860677676,
                    3.93751876765109,
                    3.94829892852543,
                    3.95907908939976,
                    3.96985925027409,
                    3.98063941114842,
                    3.99141957202275,
                    4.00219973289709,
                    4.01297989377142,
                    4.02376005464575,
                    4.03454021552008,
                    4.04532037639441,
                    4.05610053726875,
                    4.06688069814308,
                    4.07766085901741,
                    4.08844101989174,
                    4.09922118076608,
                    4.11000134164041,
                    4.12078150251474,
                    4.13156166338907,
                    4.1423418242634,
                    4.15312198513774,
                    4.16390214601207,
                    4.1746823068864,
                    4.18546246776073,
                    4.19624262863506,
                    4.2070227895094,
                    4.21780295038373,
                    4.22858311125806,
                    4.23936327213239,
                    4.25014343300672,
                    4.26092359388106,
                    4.27170375475539,
                    4.28248391562972,
                    4.29326407650405,
                    4.30404423737838,
                    4.31482439825272,
                    4.32560455912705,
                    4.33638472000138,
                    4.34716488087571,
                    4.35794504175004,
                    4.36872520262438,
                    4.37950536349871,
                    4.39028552437304,
                    4.40106568524737,
                    4.4118458461217,
                    4.42262600699604,
                    4.43340616787037,
                    4.4441863287447,
                    4.45496648961903,
                    4.46574665049336,
                    4.4765268113677,
                    4.48730697224203,
                    4.49808713311636,
                    4.50886729399069,
                    4.51964745486502,
                    4.53042761573936,
                    4.54120777661369,
                    4.55198793748802,
                    4.56276809836235,
                    4.57354825923668,
                    4.58432842011102,
                    4.59510858098535,
                    4.60588874185968,
                    4.61666890273401,
                    4.62744906360834,
                    4.63822922448268,
                    4.64900938535701,
                    4.65978954623134,
                    4.67056970710567,
                    4.68134986798,
                    4.69213002885434,
                    4.70291018972867,
                    4.713690350603,
                    4.72447051147733,
                    4.73525067235166,
                    4.746030833226,
                    4.75681099410033,
                    4.76759115497466,
                    4.77837131584899,
                    4.78915147672332,
                    4.79993163759766,
                    4.81071179847199,
                    4.82149195934632,
                    4.83227212022065,
                    4.84305228109498,
                    4.85383244196932,
                    4.86461260284365,
                    4.87539276371798,
                    4.88617292459231,
                    4.89695308546664,
                    4.90773324634098,
                    4.91851340721531,
                    4.92929356808964,
                    4.94007372896397,
                    4.9508538898383,
                    4.96163405071264,
                    4.97241421158697,
                    4.9831943724613,
                    4.99397453333563,
                    5.00475469420996,
                    5.0155348550843,
                    5.02631501595863,
                    5.03709517683296,
                    5.04787533770729,
                    5.05865549858162,
                    5.06943565945596,
                    5.08021582033029,
                    5.09099598120462,
                    5.10177614207895,
                    5.11255630295329,
                    5.12333646382762,
                    5.13411662470195,
                    5.14489678557628,
                    5.15567694645061,
                    5.16645710732494,
                    5.17723726819928,
                    5.18801742907361,
                    5.19879758994794,
                    5.20957775082227,
                    5.2203579116966,
                    5.23113807257094,
                    5.24191823344527,
                    5.2526983943196,
                    5.26347855519393,
                    5.27425871606827,
                    5.2850388769426,
                    5.29581903781693,
                    5.30659919869126,
                    5.31737935956559,
                    5.32815952043993,
                    5.33893968131426,
                    5.34971984218859,
                    5.36050000306292,
                    5.37128016393725,
                    5.38206032481158,
                    5.39284048568592,
                    5.40362064656025,
                    5.41440080743458,
                    5.42518096830891,
                    5.43596112918324,
                    5.44674129005758,
                    5.45752145093191,
                    5.46830161180624,
                    5.47908177268057,
                    5.48986193355491,
                    5.50064209442924,
                    5.51142225530357,
                    5.5222024161779,
                    5.53298257705223,
                    5.54376273792657,
                    5.5545428988009,
                    5.56532305967523,
                    5.57610322054956,
                    5.58688338142389,
                    5.59766354229822,
                    5.60844370317256,
                    5.61922386404689,
                    5.63000402492122,
                    5.64078418579555,
                    5.65156434666989,
                    5.66234450754422,
                    5.67312466841855,
                    5.68390482929288,
                    5.69468499016721,
                    5.70546515104155,
                    5.71624531191588,
                    5.72702547279021,
                    5.73780563366454,
                    5.74858579453887,
                    5.75936595541321,
                    5.77014611628754,
                    5.78092627716187,
                    5.7917064380362,
                    5.80248659891053,
                    5.81326675978486,
                    5.8240469206592,
                    5.83482708153353,
                    5.84560724240786,
                    5.85638740328219,
                    5.86716756415653,
                    5.87794772503086,
                    5.88872788590519,
                    5.89950804677952,
                    5.91028820765385,
                    5.92106836852819,
                    5.93184852940252,
                    5.94262869027685,
                    5.95340885115118,
                    5.96418901202551,
                    5.97496917289985,
                    5.98574933377418,
                    5.99652949464851,
                    6.00730965552284,
                    6.01808981639717,
                    6.02886997727151,
                    6.03965013814584,
                    6.05043029902017,
                    6.0612104598945,
                    6.07199062076883,
                    6.08277078164317,
                    6.0935509425175,
                    6.10433110339183
                  ],
                  "y": [
                    0.000340678331234312,
                    0.000380723352868235,
                    0.000424638834177929,
                    0.000474963337995418,
                    0.000529393975264593,
                    0.000588682319173735,
                    0.000656607293234329,
                    0.000729914014239381,
                    0.000809244200385803,
                    0.000900087147746019,
                    0.000997909802788136,
                    0.00110310930472324,
                    0.00122348894412429,
                    0.0013528248887647,
                    0.00149117288312956,
                    0.00164913333561658,
                    0.00181855582093685,
                    0.00199942167473366,
                    0.00220422325038804,
                    0.00242410119936976,
                    0.00265835041853829,
                    0.00292148473194166,
                    0.0032041918662996,
                    0.00350474681750114,
                    0.00383976261513001,
                    0.00419986060043966,
                    0.00458187414081252,
                    0.00500452312354923,
                    0.00545890020097555,
                    0.00593987935691386,
                    0.00646820645402869,
                    0.00703615023179504,
                    0.00763600794271693,
                    0.00829036489293674,
                    0.00899354594502326,
                    0.00973455713732782,
                    0.0105375170822025,
                    0.011399859147599,
                    0.012306496938768,
                    0.0132826478953375,
                    0.0143300611957354,
                    0.015428690250963,
                    0.0166042871506105,
                    0.0178642440188272,
                    0.0191826513455792,
                    0.0205851100894068,
                    0.0220860470112707,
                    0.0236527960341476,
                    0.0253100189022193,
                    0.0270805563700979,
                    0.0289241580808079,
                    0.0308636878728346,
                    0.0329316690911818,
                    0.0350795743177512,
                    0.0373275846362204,
                    0.0397189458418298,
                    0.0421963748914568,
                    0.0447765156276782,
                    0.0475140140698388,
                    0.0503426535788096,
                    0.0532747833236814,
                    0.0563766230170699,
                    0.0595732339460874,
                    0.0628720839025362,
                    0.0663504931146036,
                    0.0699254874004964,
                    0.0735993134307566,
                    0.0774591403204545,
                    0.0814151955281433,
                    0.0854674346119005,
                    0.0897018877518677,
                    0.0940326779025911,
                    0.0984567090511619,
                    0.103050298851152,
                    0.107739424237894,
                    0.112516104249697,
                    0.117445275006718,
                    0.122465473244922,
                    0.127564637117359,
                    0.132795053419104,
                    0.138107767545186,
                    0.143487901703603,
                    0.14897431649527,
                    0.154529683381069,
                    0.160138033677567,
                    0.165824581961215,
                    0.171561885942477,
                    0.177335039492973,
                    0.183155984529116,
                    0.189004597786179,
                    0.194869553181548,
                    0.20075048825132,
                    0.206631292496144,
                    0.212507005224319,
                    0.218366488015298,
                    0.224193743243689,
                    0.229993104211105,
                    0.235744674532209,
                    0.241428272114101,
                    0.247060449133596,
                    0.25261495593043,
                    0.258062967378506,
                    0.263436014639362,
                    0.268704157143543,
                    0.27382556867742,
                    0.278849189624442,
                    0.283744161698247,
                    0.288451670060239,
                    0.2930400065139,
                    0.297480124233002,
                    0.3016928624661,
                    0.305767178399277,
                    0.309678369510705,
                    0.313324433284999,
                    0.316815565938677,
                    0.320133606271481,
                    0.323152261812399,
                    0.32600272554287,
                    0.328675121307621,
                    0.331018594264603,
                    0.333184242696438,
                    0.335171677831677,
                    0.336806447081336,
                    0.338257625182093,
                    0.339525138018914,
                    0.340442467331994,
                    0.34116461483435,
                    0.341701436516976,
                    0.341898167801134,
                    0.341891866613966,
                    0.341702469436934,
                    0.34118954484106,
                    0.340470033316184,
                    0.339573345092245,
                    0.338375172553549,
                    0.336971376510148,
                    0.335399692949841,
                    0.333552941276864,
                    0.331506093732261,
                    0.329303601618547,
                    0.326855666993432,
                    0.324217604358639,
                    0.321438606502912,
                    0.318445838101381,
                    0.315277069557773,
                    0.311984009576258,
                    0.308509785821323,
                    0.304877434727701,
                    0.301138820012782,
                    0.297251564958368,
                    0.293227277052812,
                    0.28911559268374,
                    0.284886815004638,
                    0.280544718930806,
                    0.276134414843432,
                    0.271636841040092,
                    0.267051633713329,
                    0.262417253653655,
                    0.257723113680153,
                    0.252968327712682,
                    0.248182832836942,
                    0.243362341757138,
                    0.238508836040653,
                    0.233642159913934,
                    0.228762224593503,
                    0.223876923465975,
                    0.218994779854989,
                    0.21411794609253,
                    0.209262838284832,
                    0.204425789438312,
                    0.19960943303065,
                    0.194840829453359,
                    0.19010361107507,
                    0.18539936650125,
                    0.180767406209931,
                    0.176178496283074,
                    0.171632921487838,
                    0.167180295484824,
                    0.162781707450101,
                    0.158436365402525,
                    0.154198035182759,
                    0.150025311448062,
                    0.14591407847447,
                    0.141920130051402,
                    0.138002509045085,
                    0.134153023628654,
                    0.130427690186928,
                    0.126788418754092,
                    0.123222428371136,
                    0.119784469129956,
                    0.116441231647581,
                    0.113175048636516,
                    0.110038217991507,
                    0.107003653866291,
                    0.104048692161352,
                    0.10122227341612,
                    0.0985045554591958,
                    0.0958679209856205,
                    0.093357300045835,
                    0.0909607475238829,
                    0.0886458564861628,
                    0.0864531123765562,
                    0.084378814327179,
                    0.0823860155498833,
                    0.0805105065625621,
                    0.0787569332768955,
                    0.0770841132246185,
                    0.0755230399548137,
                    0.0740866234074945,
                    0.0727297755426221,
                    0.071478705023504,
                    0.0703543724577513,
                    0.0693081161619322,
                    0.0683614547227079,
                    0.0675431034911442,
                    0.0668011417702671,
                    0.066152547988262,
                    0.0656334539396279,
                    0.065188963361662,
                    0.0648316963653778,
                    0.0646048523099572,
                    0.0644508028297463,
                    0.0643780049878544,
                    0.0644363897767649,
                    0.0645657959809002,
                    0.0647707124084365,
                    0.0651074946175648,
                    0.0655136031738426,
                    0.0659897432391112,
                    0.0665984260809715,
                    0.0672748465408407,
                    0.0680189650892751,
                    0.0688906101420548,
                    0.0698313975430852,
                    0.0708384220629995,
                    0.071966842277876,
                    0.073166540161143,
                    0.074431144015695,
                    0.0758113818241256,
                    0.0772650333809452,
                    0.0787823885401244,
                    0.0804099589535677,
                    0.0821130922358524,
                    0.0838788482284138,
                    0.0857497095011427,
                    0.0876983002654784,
                    0.0897085413294557,
                    0.0918190456809289,
                    0.0940094588566585,
                    0.0962606395886157,
                    0.0986074632983235,
                    0.101036371670585,
                    0.103525229186553,
                    0.106105279493335,
                    0.108769556347217,
                    0.11149299532978,
                    0.114303290386701,
                    0.117199871872692,
                    0.1201548181664,
                    0.123192336029612,
                    0.126318049078034,
                    0.129501267868083,
                    0.13276276122817,
                    0.136114114020282,
                    0.139521990105868,
                    0.143003765170357,
                    0.146576699380426,
                    0.150204979508677,
                    0.153902639957811,
                    0.15769224699182,
                    0.161535747395019,
                    0.165443907395878,
                    0.169444114337411,
                    0.173496400160204,
                    0.177608373697832,
                    0.181811608229338,
                    0.186064655032629,
                    0.190372131926921,
                    0.194768978704414,
                    0.19921282927215,
                    0.203705550832135,
                    0.208284414264633,
                    0.212906846148407,
                    0.217572749743168,
                    0.222319084974573,
                    0.227105305310671,
                    0.23193083107415,
                    0.23682628191123,
                    0.24175866588389,
                    0.246725421700358,
                    0.251750699747207,
                    0.256808587644405,
                    0.261895102796974,
                    0.267027903959813,
                    0.272187469213651,
                    0.27736908280974,
                    0.282584015828395,
                    0.287818213019056,
                    0.293067044214483,
                    0.298335637882357,
                    0.303614235774592,
                    0.308899239769869,
                    0.314190030895089,
                    0.319479731579189,
                    0.324766841407028,
                    0.330045542077999,
                    0.335310183608926,
                    0.340562534201602,
                    0.345792273947459,
                    0.350993110866089,
                    0.356171339111647,
                    0.361312975346485,
                    0.366409029375443,
                    0.371471642058075,
                    0.376484130912831,
                    0.381432603063862,
                    0.38633640381407,
                    0.39117722311039,
                    0.395933958392898,
                    0.400634524978336,
                    0.40526014157602,
                    0.409780138288345,
                    0.414232342552188,
                    0.418598717384747,
                    0.422836674315555,
                    0.426995238503957,
                    0.431058364002156,
                    0.434969260406168,
                    0.438789345144572,
                    0.442505811091312,
                    0.446045515641875,
                    0.449483336034726,
                    0.452810920857362,
                    0.455936826556339,
                    0.458950293451821,
                    0.461848578253926,
                    0.464520260214079,
                    0.467069643342759,
                    0.469496481882398,
                    0.47168053735697,
                    0.473729145697963,
                    0.475646263121773,
                    0.4773120499645,
                    0.478826922342624,
                    0.480202424027657,
                    0.481320899881959,
                    0.482273495634173,
                    0.483080087888215,
                    0.483626925385245,
                    0.483993801268248,
                    0.484209462116469,
                    0.484165671682405,
                    0.483929127438391,
                    0.483537740791608,
                    0.482890250653729,
                    0.482038922272403,
                    0.481030853708671,
                    0.479773025957166,
                    0.478302403131169,
                    0.476674993280821,
                    0.47480705327058,
                    0.472719896245061,
                    0.470477846869994,
                    0.468007202999863,
                    0.465313834269649,
                    0.462469462840344,
                    0.459410895017872,
                    0.45612934329644,
                    0.452702684321975,
                    0.449078382268699,
                    0.44523435985679,
                    0.441253095384574,
                    0.437092532281297,
                    0.432719232259093,
                    0.428218439650614,
                    0.42355807225512,
                    0.418695778529832,
                    0.413717490520693,
                    0.408600283494433,
                    0.403295794262001,
                    0.39788837401148,
                    0.392363153370638,
                    0.386669026528481,
                    0.380886368374604,
                    0.375007016295244,
                    0.368980653271839,
                    0.362881227730492,
                    0.356705737941052,
                    0.350408329795132,
                    0.344054098493176,
                    0.337643474002693,
                    0.33113888380213,
                    0.324594116086427,
                    0.318009655095828,
                    0.311364756707159,
                    0.304694784277581,
                    0.298001919572985,
                    0.29128030074784,
                    0.284550249576482,
                    0.27781387529085,
                    0.271078048180862,
                    0.264351588064801,
                    0.257634819824177,
                    0.250945070231213,
                    0.244283221555707,
                    0.237646224176579,
                    0.231059539521656,
                    0.224519574261575,
                    0.218018493074123,
                    0.211587600743681,
                    0.205222070573174,
                    0.198908097881719,
                    0.192680640909631,
                    0.186536559770952,
                    0.180455162117395,
                    0.174473033422044,
                    0.168591235331646,
                    0.162781560421723,
                    0.157080410341183,
                    0.151495095934086,
                    0.145989570677362,
                    0.140598495658956,
                    0.13533697336245,
                    0.130161096839824,
                    0.125102510177794,
                    0.120185130337469,
                    0.115357458016619,
                    0.110647136819692,
                    0.106087409933429,
                    0.101619718454274,
                    0.0972670148656579,
                    0.0930718986396571,
                    0.0889695143013111,
                    0.084977713650355,
                    0.0811480481511307,
                    0.0774103171080418,
                    0.0737771213571916,
                    0.0703081873070102,
                    0.066929061617559,
                    0.0636471733308534,
                    0.0605293457206646,
                    0.0574980569041493,
                    0.0545558370868447,
                    0.0517753048208542,
                    0.049077095506481,
                    0.0464610886085763,
                    0.0439987902824508,
                    0.0416156748360275,
                    0.0393097776644996,
                    0.0371437219753179,
                    0.0350552485519824,
                    0.033038472729304,
                    0.0311474432092107,
                    0.0293314323271862,
                    0.0275812505554105,
                    0.0259428596407432,
                    0.0243760978770838,
                    0.0228691229330706,
                    0.0214604290524176,
                    0.02011930057107,
                    0.0188318981504693,
                    0.0176299555576051,
                    0.0164909986242452,
                    0.0153998224199181,
                    0.0143821548539776,
                    0.0134225350079892,
                    0.0125049769041563,
                    0.0116499701976908,
                    0.0108478660983282,
                    0.0100824186266233,
                    0.00936963113469434,
                    0.00870453307067313,
                    0.0080710651149922,
                    0.00748145814949833,
                    0.00693438263917942,
                    0.00641433264678228,
                    0.00593042585787483,
                    0.00548405256195295,
                    0.00506054612450778,
                    0.00466650490921853,
                    0.00430524417261276,
                    0.00396314474016229,
                    0.00364480825585645,
                    0.00335480898271405,
                    0.00308071167111305,
                    0.0028255709067922,
                    0.00259467918764875,
                    0.00237685818197683,
                    0.00217399384585604,
                    0.00199167286913209,
                    0.00181999288989714,
                    0.0016599826842526,
                    0.0015172040702054,
                    0.00138300585565828,
                    0.00125781012308313,
                    0.00114692602639176,
                    0.00104289490447826,
                    0.000945728744340751,
                    0.000860332995817456,
                    0.000780358487005019,
                    0.000705772389611047,
                    0.000640342666691232,
                    0.000579375782240197,
                    0.000522632687891267,
                    0.000472877334578279,
                    0.000426790910006688,
                    0.000383984237596017,
                    0.000346458197772683,
                    0.000311914308475438,
                    0.000279893176692953,
                    0.000251823431372837,
                    0.000226150738528505
                  ]
                }
              }
            },
            {
              "type": "Line",
              "id": "d2344d765d2d26d53561972e87f1dd51",
              "attributes": {
                "id": "d2344d765d2d26d53561972e87f1dd51",
                "tags": [],
                "doc": null,
                "visible": true,
                "line_color": {
                  "units": "data",
                  "value": "black"
                },
                "line_alpha": {
                  "units": "data",
                  "value": 1
                },
                "line_width": {
                  "units": "data",
                  "value": 1
                },
                "x": {
                  "units": "data",
                  "field": "x"
                },
                "y": {
                  "units": "data",
                  "field": "y"
                }
              }
            },
            {
              "type": "Line",
              "id": "8994fe0d2b96ae26da582d65ee071b96",
              "attributes": {
                "id": "8994fe0d2b96ae26da582d65ee071b96",
                "tags": [],
                "doc": null,
                "visible": true,
                "line_color": {
                  "units": "data",
                  "value": "#e1e1e1"
                },
                "line_alpha": {
                  "units": "data",
                  "value": 1
                },
                "line_width": {
                  "units": "data",
                  "value": 1
                },
                "x": {
                  "units": "data",
                  "field": "x"
                },
                "y": {
                  "units": "data",
                  "field": "y"
                }
              }
            },
            {
              "type": "Line",
              "id": "02a057b620893a0c48f0dcd8de354f02",
              "attributes": {
                "id": "02a057b620893a0c48f0dcd8de354f02",
                "tags": [],
                "doc": null,
                "visible": true,
                "line_color": {
                  "units": "data",
                  "value": "black"
                },
                "line_alpha": {
                  "units": "data",
                  "value": 1
                },
                "line_width": {
                  "units": "data",
                  "value": 1
                },
                "x": {
                  "units": "data",
                  "field": "x"
                },
                "y": {
                  "units": "data",
                  "field": "y"
                }
              }
            },
            {
              "type": "GlyphRenderer",
              "id": "c219999a52cbabb369b59cf49ad418b4",
              "attributes": {
                "id": "c219999a52cbabb369b59cf49ad418b4",
                "tags": [],
                "doc": null,
                "selection_glyph": null,
                "nonselection_glyph": {
                  "type": "Line",
                  "id": "8994fe0d2b96ae26da582d65ee071b96"
                },
                "hover_glyph": {
                  "type": "Line",
                  "id": "02a057b620893a0c48f0dcd8de354f02"
                },
                "server_data_source": null,
                "name": null,
                "data_source": {
                  "type": "ColumnDataSource",
                  "id": "b5c25518231f9d947ed8ea93bdc807a9"
                },
                "glyph": {
                  "type": "Line",
                  "id": "d2344d765d2d26d53561972e87f1dd51"
                }
              }
            },
            {
              "type": "Range1d",
              "id": "855b06b5143027e4d28fbd56f354cd1a",
              "attributes": {
                "id": "855b06b5143027e4d28fbd56f354cd1a",
                "tags": [],
                "doc": null,
                "start": 0.210062542133314,
                "end": 6.48993745786669
              }
            },
            {
              "type": "Range1d",
              "id": "38a564fc3ae79fcae972c4aedce6cc73",
              "attributes": {
                "id": "38a564fc3ae79fcae972c4aedce6cc73",
                "tags": [],
                "doc": null,
                "start": -0.0617647058823529,
                "end": 0.944117647058823
              }
            },
            {
              "type": "LinearAxis",
              "id": "c777f597c0492c638fc6ca3c9aa79eb7",
              "attributes": {
                "id": "c777f597c0492c638fc6ca3c9aa79eb7",
                "tags": [],
                "doc": null,
                "plot": {
                  "type": "Plot",
                  "id": "2bd6591010f5f4263e7539d8abd41161",
                  "subtype": "Figure"
                },
                "axis_label": "eruptions",
                "formatter": {
                  "type": "BasicTickFormatter",
                  "id": "7b1b23ee5873368b4351f68c30e66e56"
                },
                "ticker": {
                  "type": "BasicTicker",
                  "id": "9a87362cf347d9040d4e1e98f5bfb066"
                },
                "visible": true,
                "axis_label_text_font_size": "12pt"
              }
            },
            {
              "type": "BasicTickFormatter",
              "id": "7b1b23ee5873368b4351f68c30e66e56",
              "attributes": {
                "id": "7b1b23ee5873368b4351f68c30e66e56",
                "tags": [],
                "doc": null
              }
            },
            {
              "type": "BasicTicker",
              "id": "9a87362cf347d9040d4e1e98f5bfb066",
              "attributes": {
                "id": "9a87362cf347d9040d4e1e98f5bfb066",
                "tags": [],
                "doc": null,
                "num_minor_ticks": 5
              }
            },
            {
              "type": "Grid",
              "id": "37bd3b4c846f3688f2b5ff6f22ba2a29",
              "attributes": {
                "id": "37bd3b4c846f3688f2b5ff6f22ba2a29",
                "tags": [],
                "doc": null,
                "dimension": 0,
                "plot": {
                  "type": "Plot",
                  "id": "2bd6591010f5f4263e7539d8abd41161",
                  "subtype": "Figure"
                },
                "ticker": {
                  "type": "BasicTicker",
                  "id": "9a87362cf347d9040d4e1e98f5bfb066"
                }
              }
            },
            {
              "type": "LinearAxis",
              "id": "e96acc27b60637e37f71f0992e6a1759",
              "attributes": {
                "id": "e96acc27b60637e37f71f0992e6a1759",
                "tags": [],
                "doc": null,
                "plot": {
                  "type": "Plot",
                  "id": "2bd6591010f5f4263e7539d8abd41161",
                  "subtype": "Figure"
                },
                "axis_label": "Density",
                "formatter": {
                  "type": "BasicTickFormatter",
                  "id": "c43893a5d490a8537c29d04db8c7cdee"
                },
                "ticker": {
                  "type": "BasicTicker",
                  "id": "ed3cf9b6aa13bffb3258dbcca8fd4b38"
                },
                "visible": true,
                "axis_label_text_font_size": "12pt"
              }
            },
            {
              "type": "BasicTickFormatter",
              "id": "c43893a5d490a8537c29d04db8c7cdee",
              "attributes": {
                "id": "c43893a5d490a8537c29d04db8c7cdee",
                "tags": [],
                "doc": null
              }
            },
            {
              "type": "BasicTicker",
              "id": "ed3cf9b6aa13bffb3258dbcca8fd4b38",
              "attributes": {
                "id": "ed3cf9b6aa13bffb3258dbcca8fd4b38",
                "tags": [],
                "doc": null,
                "num_minor_ticks": 5
              }
            },
            {
              "type": "Grid",
              "id": "ccbad37d6b0181b634abd78597617c0c",
              "attributes": {
                "id": "ccbad37d6b0181b634abd78597617c0c",
                "tags": [],
                "doc": null,
                "dimension": 1,
                "plot": {
                  "type": "Plot",
                  "id": "2bd6591010f5f4263e7539d8abd41161",
                  "subtype": "Figure"
                },
                "ticker": {
                  "type": "BasicTicker",
                  "id": "ed3cf9b6aa13bffb3258dbcca8fd4b38"
                }
              }
            }
          ]
        }
      }
    },
    "debug": false,
    "padding": {
      "type": "figure",
      "y_pad": 10,
      "x_pad": 46
    }
  },
  "evals": [],
  "jsHooks": []
}

BokehJS

rbokeh Interface

  • Initialize a figure with figure() and add layers with pipes

  • Currently 29 layer functions (see here and here)

  • Plots are highly customizable - for further control, other pipeable functions can augment aspects of a figure, including axes, themes, and interaction tools

  • Several features you are used to in ggplot2 are available, such as aesthetics, NSE, automatic range calculation if none specified, etc.

  • In addition to figure(), there is gmap() for superposition on a google map, grid_plot() for constructing a grid of figures

figure(data = iris) %>%
  ly_points(Sepal.Length, Sepal.Width, color = Species)

20 examples in 5 minutes

1: iris data ("hello world")

figure(data = iris) %>%
  ly_points(Sepal.Length, Sepal.Width, color = Species
    hover = list(Sepal.Length, Sepal.Width))

2: custom hover and url on click

figure() %>%
  ly_points(Sepal.Length, Sepal.Width, data = iris, color = Species,
    hover = "The species of this point is '@Species'",
    url = "https://www.google.com/search?q=@Species+iris")

3: adding non-default tools (e.g. lasso select)

figure() %>% 
  ly_points(1:10) %>%
  tool_lasso_select()

# or
tools <- c("pan", "wheel_zoom", "box_zoom", "resize", "lasso_select",
  "reset", "save", "help")
figure(tools = tools) %>% 
  ly_points(1:10) %>%

See here for details and more examples

4: modifying axes

figure() %>%
  ly_points(Date, Packages, Ecdat::CRANpackages) %>%
  y_axis(log = TRUE)

See here for details and more examples

5: stat layers: model fits

z <- lm(dist ~ speed, data = cars)
figure(width = 600, height = 600) %>%
  ly_points(cars, hover = cars) %>%
  ly_lines(lowess(cars), legend = "lowess") %>%
  ly_abline(z, type = 2, legend = "lm")

6: stat layers: histogram / density

figure(width = 600, height = 400) %>%
  ly_hist(eruptions, data = faithful, breaks = 40, freq = FALSE) %>%
  ly_density(eruptions, data = faithful)

7: stat layers: hexbin

figure() %>%
  ly_hexbin(rnorm(10000), rnorm(10000))

8: stat layers: bar

figure(data = mpg, legend_location = "top_left", width = 600) %>%
  ly_bar(class, color = drv) %>%
  theme_axis("x", major_label_orientation = 45)

9: categorical axes

# prepare data
elements <- subset(elements, !is.na(group))
elements$group <- as.character(elements$group)
elements$period <- as.character(elements$period)

# add colors for groups
metals <- c("alkali metal", "alkaline earth metal", "halogen",
  "metal", "metalloid", "noble gas", "nonmetal", "transition metal")
colors <- c("#a6cee3", "#1f78b4", "#fdbf6f", "#b2df8a", "#33a02c",
  "#bbbb88", "#baa2a6", "#e08e79")
elements$color <- colors[match(elements$metal, metals)]
elements$type <- elements$metal

# make coordinates for labels
elements$symx <- paste(elements$group, ":0.1", sep = "")
elements$numbery <- paste(elements$period, ":0.8", sep = "")
elements$massy <- paste(elements$period, ":0.15", sep = "")
elements$namey <- paste(elements$period, ":0.3", sep = "")

# create figure
p <- figure(title = "Periodic Table", tools = c("resize", "hover"),
  ylim = as.character(c(7:1)), xlim = as.character(1:18),
  xgrid = FALSE, ygrid = FALSE, xlab = "", ylab = "",
  height = 445, width = 800) %>%

# plot rectangles
ly_crect(group, period, data = elements, 0.9, 0.9,
  fill_color = color, line_color = color, fill_alpha = 0.6,
  hover = list(name, atomic.number, type, atomic.mass,
    electronic.configuration)) %>%

# add symbol text
ly_text(symx, period, text = symbol, data = elements,
  font_style = "bold", font_size = "10pt",
  align = "left", baseline = "middle") %>%

# add atomic number text
ly_text(symx, numbery, text = atomic.number, data = elements,
  font_size = "6pt", align = "left", baseline = "middle") %>%

# add name text
ly_text(symx, namey, text = name, data = elements,
  font_size = "4pt", align = "left", baseline = "middle") %>%

# add atomic mass text
ly_text(symx, massy, text = atomic.mass, data = elements,
  font_size = "4pt", align = "left", baseline = "middle")

p

10: embedding images

url <- "https://raw.githubusercontent.com/weinfz/nba_shot_value_charts/master/court.png"
figure(width = 600, height = 600 * 0.7963461, padding_factor = 0,
  xlab = NULL, ylab = NULL) %>%
  ly_image_url(x = -300, y = -20, image_url = url, w = 600, h = 440, anchor = "bottom_left") %>%
  ly_points(rnorm(100, 0, 50), rnorm(100, 200, 50), color = "black")

11: creating custom layer functions

ly_baseball <- function(x) {
  base_x <- c(90 * cos(pi/4), 0, 90 * cos(3 * pi/4), 0)
  base_y <- c(90 * cos(pi/4), sqrt(90^2 + 90^2), 90 * sin(pi/4), 0)
  distarc_x <- lapply(c(2:4) * 100, function(a)
    seq(a * cos(3 * pi/4), a * cos(pi/4), length = 200))
  distarc_y <- lapply(distarc_x, function(x)
    sqrt((x[1]/cos(3 * pi/4))^2 - x^2))

  x %>%
    ## boundary
    ly_segments(c(0, 0), c(0, 0), c(-300, 300), c(300, 300), alpha = 0.4) %>%
    ## bases
    ly_crect(base_x, base_y, width = 10, height = 10,
      angle = 45*pi/180, color = "black", alpha = 0.4) %>%
    ## infield/outfield boundary
    ly_curve(60.5 + sqrt(95^2 - x^2),
      from = base_x[3] - 26, to = base_x[1] + 26, alpha = 0.4) %>%
    ly_multi_line(distarc_x, distarc_y, alpha = 0.4)
}

f <- tempfile()
download.file("https://gist.githubusercontent.com/hafen/77f25b556725b3d0066b/raw/10f0e811f09f2b9f0f9ccfb542e296dfac2761d4/doubles.csv", method="curl", f)
doubles <- read.csv(f)

figure(xgrid = FALSE, ygrid = FALSE, width = 630, height = 540,
  xlab = "Horizontal distance from home plate (ft.)",
  ylab = "Vertical distance from home plate (ft.)") %>%
  ly_baseball() %>%
  ly_hexbin(doubles, xbins = 50, shape = 0.77, alpha = 0.75, palette = "Spectral10")

Simply take a figure as input and return a modified figure as output

12: plotting on maps

bike <- read.csv("https://gist.githubusercontent.com/hafen/3d534ee95b964ef753ab/raw/dbe9f0cbe29d17151d852e8cc1c3466f7a7f02e9/201512_nycbike_summ.csv", stringsAsFactors = FALSE)
cdist <- read.csv("https://gist.githubusercontent.com/hafen/a447521ff8b24ddefba5/raw/044e174d7b9e6a370fff429f9cda4d0903b4c0a6/communitydistricts.csv")

bike$diff <- bike$n_start - bike$n_end
bike$color = ifelse(bike$diff > 0, "#2CA02C", "#D62728")

gmap(lat = 40.73306, lng = -73.97351, zoom = 12,
  width = 680, height = 600, map_style = gmap_style("blue_water")) %>%
  ly_polygons(x, y, group = which, data = cdist,
    fill_alpha = 0.1, line_width = 2, color = "orange") %>%
  ly_points(lon, lat, data = bike,
    hover = c(station, n_start, n_end, diff),
    fill_alpha = 0.8, size = abs(diff), color = color, legend = FALSE)

More tile-based map options to come

13: plotting lots of points

figure(webgl = TRUE) %>%
  ly_points(rnorm(100000), rnorm(100000), alpha = 0.2)

Not all glyphs supported by WebGL (but will soon!)

14: linked pan / zoom / brush

tools <- c("pan", "wheel_zoom", "box_zoom", "box_select", "reset")
nms <- expand.grid(names(iris)[1:4], rev(names(iris)[1:4]), stringsAsFactors = FALSE)
splom_list <- vector("list", 16)
for(ii in seq_len(nrow(nms))) {
  splom_list[[ii]] <- figure(width = 130, height = 130, tools = tools,
    xlab = nms$Var1[ii], ylab = nms$Var2[ii]) %>%
    ly_points(nms$Var1[ii], nms$Var2[ii], data = iris,
      color = Species, size = 5, legend = FALSE)
}
grid_plot(splom_list, ncol = 4, same_axes = TRUE, link_data = TRUE)

15: embed in shiny application

server <- shinyServer(function(input, output, session) {
  # Combine the selected variables into a new data frame
  selectedData <- reactive({
    iris[, c(input$xcol, input$ycol)]
  })
  clusters <- reactive({
    kmeans(selectedData(), input$clusters)
  })
  output$plot1 <- renderRbokeh({
    pal <- c("#E41A1C", "#377EB8", "#4DAF4A", "#984EA3",
      "#FF7F00", "#FFFF33", "#A65628", "#F781BF", "#999999")
    cts <- data.frame(clusters()$centers)
    figure(width = 500, height = 500) %>%
      ly_points(selectedData(), color = pal[clusters()$cluster]) %>%
      ly_points(cts, size = 40, glyph = 4, line_width = 4, color = "black")
  })
})

ui <- shinyUI(pageWithSidebar(
  headerPanel('Iris k-means clustering'),
  sidebarPanel(
    selectInput('xcol', 'X Variable', names(iris)),
    selectInput('ycol', 'Y Variable', names(iris),
      selected = names(iris)[[2]]),
    numericInput('clusters', 'Cluster count', 3,
      min = 1, max = 9)
  ),
  mainPanel(
    rbokehOutput('plot1')
  )
))

shinyApp(ui, server)

16: direct shiny interactivity

library("shiny")
library("rbokeh")
dat <- data.frame(x = rnorm(10), y = rnorm(10))

ui <- fluidPage(
  rbokehOutput("rbokeh", width = 450, height = 450),

  strong("x range change event:"),
  textOutput("x_range_text"),

  strong("y range change event:"),
  textOutput("y_range_text"),

  strong("hover event:"),
  textOutput("hover_text"),

  strong("triggered by tap/click:"),
  htmlOutput("tap_text"),

  strong("index of selected triggered by any selection:"),
  textOutput("selection_text")
)

server <- function(input, output, session) {
  output$rbokeh <- renderRbokeh({
    figure() %>%
      ly_points(x = x, y = y, data = dat,
        hover = list(x, y), lname = "points") %>%
      tool_hover(shiny_callback(id = "hover_info"), "points") %>%
      tool_tap(shiny_callback(id = "tap_info"), "points") %>%
      tool_box_select(shiny_callback(id = "selection_info"), "points") %>%
      x_range(callback = shiny_callback(id = "x_range")) %>%
      y_range(callback = shiny_callback(id = "y_range"))
  })

  output$x_range_text <- reactive({
    xrng <- input$x_range
    if(!is.null(xrng)) {
      paste0("start: ", xrng$start, ", end: ", xrng$end)
    } else {
      "waiting for x-axis pan/zoom event (use pan/zoom to trigger)..."
    }
  })

  output$y_range_text <- reactive({
    yrng <- input$y_range
    if(!is.null(yrng)) {
      paste0("start: ", yrng$start,", end: ", yrng$end)
    } else {
      "waiting for y-axis pan/zoom event (use pan/zoom to trigger)..."
    }
  })

  output$hover_text <- reactive({
    hi <- input$hover_info
    if(!is.null(hi)) {
      paste0("index: ", hi$index[["1d"]]$indices, ", x: ",
        hi$geom$sx, ", y:", hi$geom$sy)
    } else {
      "waiting for hover event (hover over plot or points on plot to trigger)..."
    }
  })

  output$tap_text <- reactive({
    ti <- input$tap_info
    if(!is.null(ti)) {
      paste("index:", paste(ti, collapse = ", "))
    } else {
      "waiting for tap/click event (click point(s) to trigger)..."
    }
  })

  output$selection_text <- reactive({
    si <- input$selection_info
    if(!is.null(si)) {
      paste("index:", paste(si, collapse = ", "))
    } else {
      "waiting for selection event (click point(s) or use box select tool to trigger)..."
    }
  })
}

shinyApp(ui, server)

17: custom JS callback 1

figure(title = "hover a blue point") %>%
  ly_points(1:10, lname = "blue", lgroup = "g1", size = 20) %>%
  ly_points(2:12, lname = "orange", lgroup = "g1") %>%
  tool_hover(custom_callback(
    code = "if(cb_data.index['1d'].indices.length > 0)
    orange_data.get('data').x[cb_data.index['1d'].indices] += 0.1
    orange_data.trigger('change')", "orange"), "blue")

18: custom JS callback 2

dat <- data.frame(x = runif(500), y = runif(500))

p <- figure(title = "select points to adjust mean line",
  tools = "lasso_select") %>%
  ly_points(x, y, data = dat, lname = "points") %>%
  ly_lines(x = c(0, 1), y = rep(mean(dat$y), 2), 
    line_width = 6, color = "orange", alpha = 0.75,
    lname = "mean")

code <- "
  var inds = cb_obj.get('selected')['1d'].indices;
  var d = cb_obj.get('data');
  var ym = 0;
  if (inds.length == 0) { return; }
  for (i = 0; i < inds.length; i++) {
    ym += d['y'][inds[i]];
  }
  ym /= inds.length;
  mean_data.get('data').y = [ym, ym];
  cb_obj.trigger('change');
  mean_data.trigger('change');
"

p %>% tool_lasso_select(
  custom_callback(code, "mean"), "points")

19: custom JS callback 3

range_callback <- custom_callback("
  var rdiff = range.get('end') - range.get('start')
  var zoomed_in = hexbin_glyph.get('_zoomed_in')
  if(rdiff < 1.5) {
    hexbin_glyph.get('_zoomed_in', true)
    points_glyph.set('visible', true)
    points_hov_glyph.set('visible', true)
    hexbin_glyph.set('visible', false)
    hexbin_hov_glyph.set('visible', false)
    hexbin_glyph.trigger('change')
    hexbin_hov_glyph.trigger('change')
    points_glyph.trigger('change')
    points_hov_glyph.trigger('change')
  } else if(rdiff >= 1.5) {
    hexbin_glyph.get('_zoomed_in', false)
    points_glyph.set('visible', false)
    points_hov_glyph.set('visible', false)
    hexbin_glyph.set('visible', true)
    hexbin_hov_glyph.set('visible', true)
    hexbin_glyph.trigger('change')
    hexbin_hov_glyph.trigger('change')
    points_glyph.trigger('change')
    points_hov_glyph.trigger('change')
  }
", c("hexbin", "points"))

figure() %>%
  ly_points(x, y, data = dat,
    visible = FALSE, lname = "points") %>%
  ly_hexbin(x, y, data = dat, hover = FALSE,
    lname = "hexbin") %>%
  x_range(callback = range_callback) %>%
  y_range(callback = range_callback)

20: embedded in trelliscope

panel <- function(x)
  figure() %>% ly_points(time, medListPriceSqft, data = x)

hcog <- function(x) {
  slp <- coef(lm(medListPriceSqft ~ time, data = x))[2]
  list(
    slope = cog(slp, desc = "list price slope"),
    meanList = cogMean(x$medListPriceSqft),
    meanSold = cogMean(x$medSoldPriceSqft)
  )
}

housingData::housing %>%
  qtrellis(by = c("county", "state"), panel, hcog, layout = c(2, 4))

Resources

install.packages("rbokeh")

Thanks

Some thoughts on interactivity in EDA

  • Data analysis is iterative and visualization is usually the driver
  • We must be able to quickly generate plots to explore, investigate ideas, validate models, etc.
  • Any interactivity in our plots must be very easily specifiable
  • This is not easy! (outside of simple but very useful transient interactions like pan / zoom / hover / click / select that we already get with things like rbokeh)
  • Something to think about: in EDA, what do we really need in terms of interactivity?
  • I actually don't think it's possible for an ad-hoc statistical visualization system to provide a flexible, rapidly specifiable interactivity scheme
  • Unless you think in terms of Trelliscope (conditioning + cognostics)

rbokeh

By Ryan Hafen

rbokeh

A Simple, Flexible, Declarative Framework for Interactive Graphics (given at useR! 2016 and JSM 2016)

  • 6,067
Loading comments...

More from Ryan Hafen