from bokeh.plotting import figure,show,output_file
output_file('lineout.html') #輸出成html檔,檔名為lineout.html
p=figure(width=800,height=400,title='零用金統計表') #圖表尺寸大小為800×400
p.title.text_color='green' #圖表標題顏色為綠色,字體大小為18
p.title.text_font_size='18pt'
p.xaxis.axis_label='年齡' #x座標名稱
p.yaxis.axis_label='零用金' #y座標名稱
listx1=[1,5,7,9,13,16] #x座標資料
listy1=[15,30,50,60,80,90] #y座標資料
dashs=[12,4] #虛線顯示點數,第一個是顯示點數為12,而空白點數為4點
p.line(listx1,listy1,line_width=4,line_color='red',line_alpha=0.3,line_dash=dashs,legend='男性') #legend是圖例所顯示的內容
listx2=[2,6,8,11,14,16]
listy2=[10,40,30,50,80,60]
p.line(listx2,listy2,line_width=4,line_color='blue',legend='女性')
show(p)

請先 登入 以發表留言。