Пример #1
0
from motion import df
from bokeh.plotting import figure, show, output_file
from bokeh.models import HoverTool, ColumnarDataSource

df["Start_string"] = df["Start"].dt.strtime("%Y-%m-%d %H:%M:%S")
df["End_string"] = df["End"].dt.strtime("%Y-%m-%d %H:%M:%S")
cds = ColumnarDataSource(df)

p = figure(x_axis_type='datetime',
           height=100,
           width=500,
           sizing_mode='scale_width',
           title="Motion Graph")
p.yaxis.minor_tick_line_color = None
p.ygrid[0].ticker.desired_num_ticks = 1

hover = HoverTool(tootips=[("Start", "@Start_string"), ("End", "@End_string")])
p.add_tools(hover)

q = p.quad(left="Start", right="End", bottom=0, top=1, source=cds)
show(p)
Пример #2
0
longs = []

with open('countries.csv') as f:

    file = csv.reader(f)

    for ab, lat, long, name in list(file)[1:]:
        lats.append(float(lat))
        longs.append(float(long))

from bokeh.io import output_file, show

from bokeh.models import GMapPlot, GMapOptions, ColumnarDataSource, Circle, Range1d, PanTool, WheelZoomTool, BoxSelectTool

map_options = GMapOptions(lat=0, lng=0, zoom=3)

plot = GMapPlot(x_range=Range1d(), y_range=Range1d(), map_options=map_options)

plot.title.text = 'Example Plot'

# plot.api_key = input('API KEY:')

source = ColumnarDataSource(data=dict(lat=lats, lon=longs))

circle = Circle(x='lon', y='lat', size=15, fill_color='red', fill_alpha=0.6)

plot.add_glyph(source, circle)
plot.add_tools(PanTool(), WheelZoomTool(), BoxSelectTool())

output_file('my_example_gmap_plot.html')
show(plot)
Пример #3
0
output_notebook()
output_file("Bokeh-Grafico-Interativo.html")
p = figure()

type(p)

p.line([1, 2, 3, 4, 5], [6, 7, 2, 4, 5], line_width=2)
show(p)

#%% Grafico de barras
output_file("Bokeh-Grafico-Barras.html")

fruits = ['Maças', 'Peras', 'Tangerinas', 'Uvas', 'Melancias', 'Morangos']
counts = [5, 3, 4, 2, 4, 6]

source = ColumnarDataSource(data=dict(fruits=fruits, counts=counts))

p = figure(x_range=fruits,
           plot_height=350,
           toolbar_location=None,
           title='Contagem de frutas')

p.vbar(x='fruits',
       top='counts',
       width=0.9,
       source=source,
       legend='fruits',
       line_color='white',
       fill_color=factor_cmap('fruits', palette=None, factors=fruits))

p.xgrid.grid_line_color = None
Пример #4
0
data_final_q1 = pd.merge(data_kw_score,data_rj_score,left_index = True,right_index = True)
data_final_q1 = pd.merge(data_final_q1,data_xjb_score,left_index = True,right_index = True)
# 数据合并


'''
③绘制图表辅助分析
'''
import bokeh.layouts
import gridplot

data_final_q1['size'] =data_final_q1['口味_norm'] * 40
data_final_q1.index.name = 'type'
data_final_q1.columns = ['kw','kw_norm','price','price_norm','xjb','xjb_norm','size']
# 将列名改为英文

source = ColumnarDataSource(data_final_q1)
#创建数据

result = figure(plot_width = 800,plot_height = 300,title = '餐饮类型得分',
				x_axis_lable = '人均消费' ,y_axis_lable = '性价比得分')
result.circle(x = 'price',y = 'xjb_norm',source = source,line_color = 'black',
			  line_dash = [6,4],fill_alpha = 0.6,size = 'size')
# 散点图

data_type = data_final_q1.index.tolist()

kw = figure(plot_width = 800,plot_heght = 300 ,title = '口味得分', x_range = data_type)
kw.vbar(x='type')