Пример #1
0
def make_plot(name, glyph):
    glyph_renderer = GlyphRenderer(
        data_source=source,
        xdata_range=xdr,
        ydata_range=ydr,
        glyph=glyph,
    )

    pantool = PanTool(dataranges=[xdr, ydr], dimensions=["width", "height"])
    zoomtool = ZoomTool(dataranges=[xdr, ydr], dimensions=("width", "height"))

    plot = Plot(x_range=xdr, y_range=ydr, data_sources=[source], border=80)
    xaxis = LinearAxis(plot=plot, dimension=0)
    yaxis = LinearAxis(plot=plot, dimension=1)
    xgrid = Rule(plot=plot, dimension=0)
    ygrid = Rule(plot=plot, dimension=1)

    plot.renderers.append(glyph_renderer)
    plot.tools = [pantool, zoomtool]

    sess = session.PlotServerSession(username="******",
                                     serverloc="http://localhost:5006",
                                     userapikey="nokey")
    sess.add(plot, glyph_renderer, xaxis, yaxis, xgrid, ygrid, source, xdr,
             ydr, pantool, zoomtool)
    sess.use_doc(name)
    sess.store_all()
Пример #2
0
def make_plot(name, glyph):
    glyph_renderer = GlyphRenderer(
        data_source=source,
        xdata_range=xdr,
        ydata_range=ydr,
        glyph=glyph,
    )

    pantool = PanTool(dataranges=[xdr, ydr], dimensions=["width", "height"])
    zoomtool = ZoomTool(dataranges=[xdr, ydr], dimensions=("width", "height"))

    plot = Plot(x_range=xdr, y_range=ydr, data_sources=[source], border=80)
    xaxis = LinearAxis(plot=plot, dimension=0)
    yaxis = LinearAxis(plot=plot, dimension=1)
    xgrid = Grid(plot=plot, dimension=0)
    ygrid = Grid(plot=plot, dimension=1)

    plot.renderers.append(glyph_renderer)
    plot.tools = [pantool, zoomtool]

    try:
        sess = session.PlotServerSession(username="******",
                                         serverloc="http://localhost:5006",
                                         userapikey="nokey")
    except requests.exceptions.ConnectionError as e:
        print e
        print "\nThis example requires the plot server.  Please make sure plot server is running, via 'python runserver.py' in the bokeh root directory.\n"
        sys.exit()
    sess.add(plot, glyph_renderer, xaxis, yaxis, xgrid, ygrid, source, xdr,
             ydr, pantool, zoomtool)
    sess.use_doc(name)
    sess.plotcontext.children.append(plot)
    sess.plotcontext._dirty = True
    sess.store_all()
Пример #3
0
def make_plot(name, glyph):
    glyph_renderer = Glyph(
        data_source=source,
        xdata_range=xdr,
        ydata_range=ydr,
        glyph=glyph,
    )

    pantool = PanTool(dimensions=["width", "height"])
    wheelzoomtool = WheelZoomTool(dimensions=["width", "height"])

    plot = Plot(x_range=xdr, y_range=ydr, data_sources=[source], min_border=80)
    xaxis = LinearAxis(plot=plot, dimension=0)
    yaxis = LinearAxis(plot=plot, dimension=1)
    xgrid = Grid(plot=plot, dimension=0, axis=xaxis)
    ygrid = Grid(plot=plot, dimension=1, axis=yaxis)

    plot.renderers.append(glyph_renderer)
    plot.tools = [pantool, wheelzoomtool]

    try:
        sess = session.PlotServerSession(serverloc="http://localhost:5006",
                                         username="******",
                                         userapikey="nokey")
    except requests.exceptions.ConnectionError:
        print(
            "ERROR: This example requires the plot server. Please make sure plot server is running, by executing 'bokeh-server'"
        )
        sys.exit(1)

    sess.use_doc(name)
    sess.add_plot(plot)
    sess.store_all()
Пример #4
0
                data_sources=[],
                canvas_width=600,
                canvas_height=600,
                outer_width=600,
                outer_height=600,
                title="Austin")

select_tool = SelectionTool()
overlay = BoxSelectionOverlay(tool=select_tool)
plot.renderers.append(overlay)
plot.tools.append(select_tool)

xgrid = Grid(plot=plot, dimension=0)
ygrid = Grid(plot=plot, dimension=1)
pantool = PanTool(plot=plot)
zoomtool = ZoomTool(plot=plot)
plot.tools.extend([pantool, zoomtool])

sess = session.PlotServerSession(username="******",
                                 serverloc="http://localhost:5006",
                                 userapikey="nokey")

sess.use_doc("maps")
sess.add(plot, xgrid, ygrid, pantool, zoomtool, x_range, y_range, select_tool,
         overlay)
sess.plotcontext.children.append(plot)
sess.plotcontext._dirty = True
sess.store_all()

print "Stored to document maps"
Пример #5
0
def generate_embed_test():
    """this generates a new plot and uses the script inject to put it
    into a page running this repeatedly will fill up your redis DB
    quickly, but it allows quick iteration

    """

    from numpy import pi, arange, sin, cos
    import numpy as np

    from bokeh.objects import (
        Plot, DataRange1d, LinearAxis, Rule,
        ColumnDataSource, GlyphRenderer, 
        PanTool, ZoomTool, PreviewSaveTool)

    from bokeh.glyphs import Circle
    from bokeh import session

    x = arange(-2*pi, 2*pi, 0.1)
    y = sin(x)
    z = cos(x)
    widths = np.ones_like(x) * 0.02
    heights = np.ones_like(x) * 0.2


    source = ColumnDataSource(data=dict(x=x,y=y,z=z,widths=widths,
                                    heights=heights))

    xdr = DataRange1d(sources=[source.columns("x")])
    ydr = DataRange1d(sources=[source.columns("y")])

    circle = Circle(x="x", y="y", fill="red", radius=5, line_color="black")

    glyph_renderer = GlyphRenderer(
        data_source = source,
        xdata_range = xdr,
        ydata_range = ydr,
        glyph = circle)


    pantool = PanTool(dataranges = [xdr, ydr], dimensions=["width","height"])
    #zoomtool = ZoomTool(dataranges=[xdr,ydr], dimensions=("width","height"))
    previewtool = PreviewSaveTool(dataranges=[xdr,ydr], dimensions=("width","height"))

    plot = Plot(x_range=xdr, y_range=ydr, data_sources=[source],
                border= 80)
    xaxis = LinearAxis(plot=plot, dimension=0)
    yaxis = LinearAxis(plot=plot, dimension=1)
    xgrid = Rule(plot=plot, dimension=0)
    ygrid = Rule(plot=plot, dimension=1)

    plot.renderers.append(glyph_renderer)
    plot.tools = [pantool, previewtool]

    sess = session.PlotServerSession(
        username="******", 
        serverloc="http://localhost:5006", userapikey="nokey")
    sess.use_doc("glyph2")
    sess.add(plot, glyph_renderer, xaxis, yaxis, xgrid, ygrid, source, 
             xdr, ydr, pantool, previewtool)
    sess.plotcontext.children.append(plot)
    sess.plotcontext._dirty = True
    # not so nice.. but set the model doens't know
    # that we appended to children
    sess.store_all()

    if app.debug:
        slug = hemlib.slug_json()
        static_js = hemlib.slug_libs(app, slug['libs'])
        hemsource = os.path.join(app.static_folder, "coffee")
        hem_js = hemlib.coffee_assets(hemsource, "localhost", 9294)
        hemsource = os.path.join(app.static_folder, "vendor",
                                 "bokehjs", "coffee")
        hem_js += hemlib.coffee_assets(hemsource, "localhost", 9294)
    else:
        static_js = ['/bokeh/static/js/application.js']
        hem_js = []
    return render_template("generate_embed_test.html", jsfiles=static_js, hemfiles=hem_js, 
                           plot_scr=plot.script_inject())
Пример #6
0
def make_plot():

    from numpy import pi, arange, sin, cos
    import numpy as np

    from bokeh.objects import (Plot, DataRange1d, LinearAxis, ColumnDataSource,
                               GlyphRenderer, PanTool, PreviewSaveTool)

    from bokeh.glyphs import Circle
    from bokeh import session

    x = arange(-2 * pi, 2 * pi, 0.1)
    y = sin(x)
    z = cos(x)
    widths = np.ones_like(x) * 0.02
    heights = np.ones_like(x) * 0.2

    source = ColumnDataSource(
        data=dict(x=x, y=y, z=z, widths=widths, heights=heights))

    xdr = DataRange1d(sources=[source.columns("x")])
    ydr = DataRange1d(sources=[source.columns("y")])

    circle = Circle(x="x", y="y", fill="red", radius=5, line_color="black")

    glyph_renderer = GlyphRenderer(data_source=source,
                                   xdata_range=xdr,
                                   ydata_range=ydr,
                                   glyph=circle)

    pantool = PanTool(dataranges=[xdr, ydr], dimensions=["width", "height"])
    previewtool = PreviewSaveTool(dataranges=[xdr, ydr],
                                  dimensions=("width", "height"))

    plot = Plot(x_range=xdr, y_range=ydr, data_sources=[source], border=80)
    xaxis = LinearAxis(plot=plot, dimension=0)
    yaxis = LinearAxis(plot=plot, dimension=1)

    plot.renderers.append(glyph_renderer)
    plot.tools = [pantool, previewtool]

    sess = session.PlotServerSession(username="******",
                                     serverloc="http://localhost:5006",
                                     userapikey="nokey")
    sess.use_doc("glyph2")
    sess.add(
        plot,
        glyph_renderer,
        xaxis,
        yaxis,  # xgrid, ygrid,
        source,
        xdr,
        ydr,
        pantool,
        previewtool)
    sess.plotcontext.children.append(plot)
    sess.plotcontext._dirty = True
    # not so nice.. but set the model doens't know
    # that we appended to children
    sess.store_all()
    return plot