コード例 #1
0
ファイル: prim.py プロジェクト: louisshih/Bokeh
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 line_advanced():

    source = ColumnDataSource(data=dict(x=x,y=y,z=z,widths=widths,
                heights=heights))
    
    xdr = DataRange1d(sources=[source.columns("x")])
    xdr2 = DataRange1d(sources=[source.columns("x")])
    ydr = DataRange1d(sources=[source.columns("y")])
    ydr2 = DataRange1d(sources=[source.columns("y")])
    
    line_glyph = Line(x="x", y="y", line_color="blue")
    
    renderer = GlyphRenderer(data_source = source,  xdata_range = xdr,
            ydata_range = ydr, glyph = line_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=50)
    plot.tools = [pantool, zoomtool]
    plot.renderers.append(renderer)
    
    #notice that these two have a differen y data range
    renderer2 = GlyphRenderer(data_source = source, xdata_range = xdr,
            ydata_range = ydr2, glyph = line_glyph)
    
    plot2 = Plot(x_range=xdr, y_range=ydr2, data_sources=[source], 
            border=50)
    
    plot2.renderers.append(renderer2)
    
    #notice that these two have a differen y data range
    renderer3 = GlyphRenderer(data_source = source, xdata_range = xdr2,
            ydata_range = ydr, glyph = line_glyph)
    
    plot3 = Plot(x_range=xdr2, y_range=ydr, data_sources=[source], 
            border=50)
    
    plot3.renderers.append(renderer3)
    
    #this is a dummy plot with no renderers
    plot4 = Plot(x_range=xdr2, y_range=ydr, data_sources=[source], 
            border=50)
    
    
    sess = session.HTMLFileSession("line_linked_advanced.html")
    sess.add(plot, renderer, source, xdr, ydr, pantool, zoomtool)
    
    sess.add(plot2, renderer2, ydr2, xdr2, renderer3, plot3, plot4)
    grid = GridPlot(children=[[plot, plot2], [plot3, plot4 ]], name="linked_advanced")
    
    sess.add(grid)
    sess.plotcontext.children.append(grid)
    
    
    sess.save(js="relative", css="relative", rootdir=os.path.abspath("."))
    print "Wrote line_linked_advanced.html"
    
        webbrowser.open("file://" + os.path.abspath("line_linked_advanced.html"))
コード例 #4
0
def make_plot(source, xname, yname, linecolor, xdr=None, ydr=None):
    """ Returns a tuple (plot, [obj1...objN]); the former can be added
    to a GridPlot, and the latter is added to the plotcontext.
    """

    if xdr is None:
        xdr = DataRange1d(sources=[source.columns(xname)])
    if ydr is None:
        ydr = DataRange1d(sources=[source.columns(yname)])
    plot = Plot(x_range=xdr, y_range=ydr, data_sources=[source], border=50)
    xaxis = LinearAxis(plot=plot, dimension=0, location="bottom")
    yaxis = LinearAxis(plot=plot, dimension=1, location="left")
    pantool = PanTool(dataranges=[xdr, ydr], dimensions=["width", "height"])
    zoomtool = ZoomTool(dataranges=[xdr, ydr], dimensions=("width", "height"))
    renderer = GlyphRenderer(
        data_source=source,
        xdata_range=xdr,
        ydata_range=ydr,
        glyph=Line(x=xname, y=yname, linecolor=linecolor),
    )
    plot.renderers.append(renderer)
    plot.tools = [pantool, zoomtool]
    return plot, (renderer, xaxis, yaxis, source, xdr, ydr, pantool, zoomtool)
コード例 #5
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"
コード例 #6
0
                                    sepal_width=flowers['sepal_width'],
                                    color=flowers['color']))

text_source = ColumnDataSource(data=dict(center=[125]))

xdr = DataRange1d(sources=[
    source.columns("petal_length", "petal_width", "sepal_length",
                   "sepal_width")
])
ydr = DataRange1d(sources=[
    source.columns("petal_length", "petal_width", "sepal_length",
                   "sepal_width")
])

pan = PanTool(dataranges=[xdr, ydr], dimensions=["x", "y"])
zoom = ZoomTool(dataranges=[xdr, ydr], dimensions=["x", "y"])


def make_plot(xname, yname, xax=False, yax=False, text=None):
    plot = Plot(x_range=xdr,
                y_range=ydr,
                data_sources=[source],
                background_fill="#ffeedd",
                width=250,
                height=250,
                border_fill='white',
                title="",
                border_symmetry="",
                min_border=2)
    objs = []
    if xax:
コード例 #7
0
#        ])

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

circle = Circle(x="x", y="y", fill_color="red", radius="z", 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"))

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

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

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