{ "metadata": { "name": "", "signature": "sha256:9afb7e31d75c9582e349ec5fba1fcf7be8b875bc32ebef4dc86f657bf02f5515" }, "nbformat": 3, "nbformat_minor": 0, "worksheets": [ { "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "
Configuring embedded BokehJS mode.
\n", " \n", "" ], "metadata": {}, "output_type": "display_data" } ], "prompt_number": 2 }, { "cell_type": "markdown", "metadata": {}, "source": [ "Next, we'll import NumPy and create some simple data." ] }, { "cell_type": "code", "collapsed": false, "input": [ "from numpy import *\n", "x = linspace(-6, 6, 100)\n", "y = cos(x)" ], "language": "python", "metadata": {}, "outputs": [], "prompt_number": 3 }, { "cell_type": "markdown", "metadata": {}, "source": [ "Now we'll call Bokeh's `circle()` function to render a red circle at\n", "each of the points in x and y.\n", "\n", "We can immediately interact with the plot:\n", "\n", " * click-and-drag will pan the plot around.\n", " * Shift + mousewheel will zoom in and out\n", " \n", "(The toolbar is simply a default one that is available for all plots;\n", "this can be configured dynamically via the `tools` keyword argument.)" ] }, { "cell_type": "code", "collapsed": false, "input": [ "circle(x, y, color=\"red\", plot_width=500, plot_height=500)\n", "show()" ], "language": "python", "metadata": {}, "outputs": [ { "html": [ "\n", "\n", " \n", " \n", "\n", " | \n", " | \n", " |
Configuring embedded BokehJS mode.
\n", " \n", "" ], "metadata": {}, "output_type": "display_data" }, { "html": [ "\n", "\n", " \n", " \n", "Configuring embedded BokehJS mode.
\n", " \n", "" ], "metadata": {}, "output_type": "display_data" } ], "prompt_number": 8 }, { "cell_type": "markdown", "metadata": {}, "source": [ "Server-based Plotting\n", "---------------------\n", "\n", "The above plots are all embedded fully inside the notebook. This means that if you nbconvert\n", "or ship the notebook file around, all the examples remain fully interactive.\n", "\n", "But what if your data exceeds what is reasonable to embed in a notebook or HTML file?\n", "\n", "Bokeh also supports storing data inside the bokeh server, which is launched at\n", "the command line:\n", "\n", " $ bokeh-server\n", " \n", "After this is run, then any of the examples in [`examples/plotting/server/`](https://github.com/ContinuumIO/bokeh/tree/master/examples/plotting/server) can\n", "be run.\n", "\n", "This includes animated plots:\n", "\n", "\n", "\n", "\n" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Plotting \"Apps\"\n", "---------------\n", "\n", "When the linked brushing and server-based operation are combined,\n", "you can build graphical \"applets\", which resemble things like\n", "what Crossfilter and others do. However, Bokeh provides the\n", "reactive object model across client and server, so these sorts\n", "of selections and interactions can trigger server-side code,\n", "which is implemented in Python.\n", "\n", "*(Click to launch the live app.)*\n", "\n", "\n", "\n" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Downsampling\n", "------------\n", "\n", "The Bokeh plot server also has basic downsampling capability.\n", "This is an area that is under active development, and is one\n", "of the core design goals for Bokeh. Currently only line and\n", "image plots are supported, but techniques are under development\n", "for better, semantic downsampling of other visual forms.\n", "\n", "The following interactive plot displays 4.2gb of historical\n", "ocean temperature data. The left slider moves through time,\n", "and the right and bottom sliders affect the bottom and right\n", "plots. When you zoom on the main plot area, the server performs\n", "realtime downsampling on the data cube, and only sends the \n", "relevant data to the client.\n", "\n", "*(Click to launch a new tab with the interactive app)*\n", "\n", "\n", "\n" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "BokehJS\n", "-------\n", "\n", "At its core, Bokeh consists of a Javascript library (which we call \n", "[BokehJS](https://github.com/ContinuumIO/bokeh/tree/master/bokehjs)),\n", "and a Python binding which provides classes and objects that ultimately\n", "generate a JSON representation of the plot structure.\n", "\n", "You can read more about design and usage in the \n", "[BokehJS section of the Bokeh Developer Guide](http://bokeh.pydata.org/docs/dev_guide.html#bokehjs).\n", "\n", "BokehJS can be used entirely from Javascript. For instance, here is an\n", "embedded [JSFiddle](http://jsfiddle.net) that allows you to manipulate\n", "a plot. Click the \"Edit in JSFiddle\" to launch a JSFiddle window that\n", "lets you edit the Coffeescript source live:" ] }, { "cell_type": "code", "collapsed": false, "input": [ "from IPython.display import IFrame\n", "IFrame(\"http://jsfiddle.net/3VNuN/4/embedded/result%2Cjs/\", 800, 400)" ], "language": "python", "metadata": {}, "outputs": [ { "html": [ "\n", " \n", " " ], "metadata": {}, "output_type": "pyout", "prompt_number": 9, "text": [ "