July 23, 2018

Python bokeh glyph packages

bokeh glyph packages in Python

from bokeh.io import output_file, show ## glyph
from bokeh.plotting import figure
from bokeh.sampledata.iris import flowers

plot = figure()
plot = figure(plot_width=400, tools='pan,box_zoom')
p = figure(x_axis_label='fertility (children per woman)', y_axis_label='female_literacy (% population)')
p = figure(x_axis_type='datetime', x_axis_label='Date', y_axis_label='US Dollars')
plot = figure(tools='box_select, lasso_select')
plot = figure(tools=[hover, 'crosshair'])
p = figure( tools="pan,box_zoom, reset, save", y_axis_type="log", y_range=[0.001, 10**11], title="log axis example", x_axis_label='sections', y_axis_label='particles')
right = figure(tools=TOOLS, width=350, height=350, title=None)
p = figure(plot_width=400, plot_height=400)

p.circle([1,2,3,4],[8,3,2,6])
p.circle(fertility_africa, female_literacy_africa, color='red', size=10, alpha=0.8)
plot.circle(x=10, y=[2,4,7,11], size=[10,20,30,40])
plot.circle(x, y, fill_color='white', size=10, hover_color='red')
p.circle(df['hp'], df['mpg'], color=df['color'], size=10)
p.circle(source=source, x='Year', y='Time', color='color', size=8)
p.circle(plength, slength, color={'field':'species', 'transform':mapper}, selection_color='red', nonselection_fill_alpha=0.2, nonselection_fill_color='grey')
p.circle('weight', 'mpg', source=source, color=dict(field='origin', transform=color_mapper),  legend='origin')
p.line(x, y2, legend="y=10^x^2", line_color="orange", line_dash="4 4", radius=radii, fill_color=colors, fill_alpha=0.6)

s2.triangle(x, y1, size=10, color="firebrick", alpha=0.5)
s3.square(x, y2, size=10, color="olive", alpha=0.5)
p.square([1, 2, 3, 4, 5], [6, 7, 2, 4, 5], size=20, color="olive", alpha=0.5)
p = gridplot([[left, right]])
p = gridplot([[s1, s2, s3]], toolbar_location=None)
p.quad(top=[2, 3, 4], bottom=[1, 2, 3], left=[1, 2, 3], right=[1.2, 2.5, 3.7], color="#B3DE69")
p.rect(x=[1, 2, 3], y=[1, 2, 3], width=0.2, height=40, color="#CAB2D6", angle=pi/3, height_units="screen")
p.vbar(x=[1, 2, 3], width=0.5, bottom=0, top=[1.2, 2.5, 3.7], color="firebrick")
p.hbar(y=[1, 2, 3], height=0.5, left=0, right=[1.2, 2.5, 3.7], color="navy")
p.oval(x=[1, 2, 3], y=[1, 2, 3], width=0.2, height=40, color="#CAB2D6", angle=pi/3, height_units="screen")
p.ellipse(x=[1, 2, 3], y=[1, 2, 3], width=[0.2, 0.3, 0.1], height=0.3, angle=pi/3, color="#CAB2D6")
p.arc(x=[1, 2, 3], y=[1, 2, 3], radius=0.1, start_angle=0.4, end_angle=4.8, color="navy")
p.wedge(x=[1, 2, 3], y=[1, 2, 3], radius=0.2, start_angle=0.4, end_angle=4.8, color="firebrick", alpha=0.6, direction="clock")
p.annular_wedge(x=[1, 2, 3], y=[1, 2, 3], inner_radius=0.1, outer_radius=0.25, start_angle=0.4, end_angle=4.8, color="green", alpha=0.6)
p.annulus(x=[1, 2, 3], y=[1, 2, 3], inner_radius=0.1, outer_radius=0.25, color="orange", alpha=0.6)

output_file('circle.html')
output_file("stocks.html", title="stocks.py example")
show(plot)
p.x(fertility_africa,female_literacy_africa)
p.line(date, price)
plot.line(x, y, line_width=3)
p.line(aapl_dates, aapl_avg, color='navy', legend='avg')
p.multi_line([[1, 3, 2], [3, 4, 6, 6]], [[2, 1, 4], [4, 7, 8, 5]], color=["firebrick", "navy"], alpha=[0.8, 0.3], line_width=4)
p.patch([1, 2, 3, 4, 5], [6, 7, 8, 7, 3], alpha=0.5, line_width=2)
p.patches(x,y, line_color='white')
plot.patches(xs, ys, fill_color=['red','blue','green'], line_color='white')
p.patches([[1, 3, 2], [3, 4, 6, 6]], [[2, 1, 4], [4, 7, 8, 5]], color=["firebrick", "navy"], alpha=[0.8, 0.3], line_width=2)
p.patch([1, 2, 3, nan, 4, 5, 6], [6, 7, 5, nan, 7, 3, 6], alpha=0.5, line_width=2)
p.image_rgba(image=[img], x=[0], y=[0], dw=[10], dh=[10])
p.segment(x0=[1, 2, 3], y0=[1, 2, 3], x1=[1.2, 2.4, 3.1],  y1=[1.2, 2.5, 3.7], color="#F4A582", line_width=3)
p.ray(x=[1, 2, 3], y=[1, 2, 3], length=45, angle=[30, 45, 60], angle_units="deg", color="#FB8072", line_width=2)
p.y_range = Range1d(0, 15)
p.add_layout(LinearAxis(y_range_name="foo"), 'left')

p.title.text = "Python bokeh glyph packages in Python"
p.legend.location = "top_left"
p.grid.grid_line_alpha=0
p.xaxis.axis_label = 'Date'
p.yaxis.axis_label = 'Price'
p.ygrid.band_fill_color="olive"
p.ygrid.band_fill_alpha = 0.1

from bokeh.modes import ColumnDataSource

src = ColumnDataSource(data={'x':[1,2,3,4], 'y':=[8,6,4,2]})
src = ColumnDataSource(df)
src.data

from bokeh.modes import HovelTool
hv = HoverTool(tooltips=None, mode='hline')
hover = HoverTool(tooltips=None, mode='vline')
p.add_tools(hover)
plot.add_tools(PanTool(), WheelZoomTool(), BoxSelectTool())

from bokeh.modes import CategoricalColorMapper

mapper = CategoricalColorMapper(factors=['setosa', 'virginca', 'versicolor'], palette=['red','blue','green'])

from bokeh.io import export_png
export_png(plot, filename="plot.png")

from bokeh.sampledata.sample_geojson import geojson
geo_source = GeoJSONDataSource(geojson=geojson)

from bokeh.models import (GMapPlot, GMapOptions, ColumnDataSource, Circle, DataRange1d, PanTool, WheelZoomTool, BoxSelectTool)
map_options = GMapOptions(lat=30.29, lng=-97.73, map_type="roadmap", zoom=11)

Related Python Articles:  scipy package in Python         pandas

No comments:

Post a Comment