コード例 #1
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"))
コード例 #2
0
sess = session.HTMLFileSession("iris_splom.html")
attrs = ["petal_length", "petal_width", "sepal_width", "sepal_length"]

plots = []
for y in attrs:
    row = []
    for x in attrs:
        xax = (y == attrs[-1])
        yax = (x == attrs[0])
        text = x if (x == y) else None
        plot, objs = make_plot(x, y, xax, yax, text)
        sess.add(plot, *objs)
        row.append(plot)
    plots.append(row)

grid = GridPlot(children=plots, name="iris_splom")

sess.add(source, xdr, ydr, pan, zoom)
sess.add(grid)
sess.plotcontext.children.append(grid)
sess.save(js="relative", css="relative", rootdir=os.path.abspath("."))

if __name__ == "__main__":
    try:
        iris_splom()
        import webbrowser
        webbrowser.open("file://" + os.path.abspath("iris_splom.html"))
    except:
        pass
コード例 #3
0
ファイル: anscombe.py プロジェクト: weikang9009/bokeh
    plot.add_glyph(lines_source, line)

    circle = Circle(x=xname,
                    y=yname,
                    size=12,
                    fill_color="#cc6633",
                    line_color="#cc6633",
                    fill_alpha=0.5)
    plot.add_glyph(circles_source, circle)

    return plot


#where will this comment show up
I = make_plot('I', 'xi', 'yi')
II = make_plot('II', 'xii', 'yii')
III = make_plot('III', 'xiii', 'yiii')
IV = make_plot('IV', 'xiv', 'yiv')

grid = GridPlot(children=[[I, II], [III, IV]], plot_width=800)

doc = Document()
doc.add(grid)

if __name__ == "__main__":
    filename = "anscombe.html"
    with open(filename, "w") as f:
        f.write(file_html(doc, INLINE, "Anscombe's Quartet"))
    print("Wrote %s" % filename)
    view(filename)
コード例 #4
0
ファイル: iris_splom.py プロジェクト: weikang9009/bokeh
        plot.add_glyph(text_source, text)

    return plot


xattrs = ["petal_length", "petal_width", "sepal_width", "sepal_length"]
yattrs = list(reversed(xattrs))
plots = []

for y in yattrs:
    row = []
    for x in xattrs:
        xax = (y == yattrs[-1])
        yax = (x == xattrs[0])
        text = x if (x == y) else None
        plot = make_plot(x, y, xax, yax, text)
        row.append(plot)
    plots.append(row)

grid = GridPlot(children=plots, title="iris_splom")

doc = Document()
doc.add(grid)

if __name__ == "__main__":
    filename = "iris_splom.html"
    with open(filename, "w") as f:
        f.write(file_html(doc, INLINE, "Iris Data SPLOM"))
    print("Wrote %s" % filename)
    view(filename)
コード例 #5
0
ファイル: grid.py プロジェクト: terrycojones/bokeh
    yaxis = LinearAxis(plot=plot, dimension=1, location="left")
    pantool = PanTool(dataranges=[xdr, ydr], dimensions=["width", "height"])
    wheelzoomtool = WheelZoomTool(dataranges=[xdr, ydr],
                                  dimensions=("width", "height"))
    renderer = Glyph(
        data_source=source,
        xdata_range=xdr,
        ydata_range=ydr,
        glyph=Line(x=xname, y=yname, linecolor=linecolor),
    )
    plot.renderers.append(renderer)
    plot.tools = [pantool, wheelzoomtool]
    return plot


plot1 = make_plot(source, "x", "y1", "blue")
plot2 = make_plot(source, "x", "y2", "red", xdr=plot1.x_range)
plot3 = make_plot(source, "x", "y3", "green")
plot4 = make_plot(source, "x", "y4", "black")

grid = GridPlot(children=[[plot1, plot2], [plot3, plot4]])

sess = session.HTMLFileSession("grid.html")
sess.add(grid, recursive=True)
sess.plotcontext.children.append(grid)
sess.save(js="absolute", css="absolute")
print("Wrote %s" % sess.filename)

if __name__ == "__main__":
    sess.view()
コード例 #6
0
ファイル: anscombe.py プロジェクト: dasfaha/bokeh
                     radius=6,
                     fill_color="#cc6633",
                     line_color="#cc6633",
                     fill_alpha=0.5),
    )
    plot.renderers.append(circle_renderer)
    return plot, (line_renderer, circle_renderer, xaxis, yaxis, xgrid, ygrid)


#where will this comment show up
I, objsI = make_plot('I', 'xi', 'yi')
II, objsII = make_plot('II', 'xii', 'yii')
III, objsIII = make_plot('III', 'xiii', 'yiii')
IV, objsIV = make_plot('IV', 'xiv', 'yiv')

grid = GridPlot(children=[[I, II], [III, IV]], width="800px")

sess = session.HTMLFileSession("anscombe.html")
sess.add(lines_source, circles_source, xdr, ydr)
sess.add(*(objsI + objsII + objsIII + objsIV))
sess.add(grid, I, II, III, IV)
sess.plotcontext.children.append(grid)
sess.save(js="relative", css="relative", rootdir=os.path.abspath("."))

if __name__ == "__main__":
    try:
        import webbrowser
        webbrowser.open("file://" + os.path.abspath("anscombe.html"))
    except:
        pass