2017-11-04 141 views
0

我是新來的方法。我創建了以下輸入,但它給了我一個空輸出。我錯過了什麼?謝謝。散景簡單條形圖

import pandas as pd 
from bokeh.charts import Bar 
import pandas as pd 
from bokeh.plotting import figure, output_file, show 
mortality_age = pd.read_csv("mortality_by_age.csv") 
x=mortality_age["Age Range"] 
y=mortality_age["Deaths per 100,000 Live Births:"] 
plot = figure(title="Example of a vertical bar chart") 
plot.vbar(x, top=y, width=0.5,color="#CAB2D6") 
output_file("vertical_bar.html", mode="inline") 
show(plot) 

回答

0

您使用的是什麼版本的散景?

使用12.10,我設法使用下面的代碼來顯示一個圖,使用documentation中包含的示例。

# import pandas as pd 
from bokeh.plotting import figure, output_file, show 
# from bokeh.charts import Bar # I had issues with this line working 
# mortality_age = pd.read_csv("mortality_by_age.csv") 
# x=mortality_age["Age Range"] 
# y=mortality_age["Deaths per 100,000 Live Births:"] 
x=[1, 2, 3, 4, 5] 
y=[6, 7, 6, 4, 5] 
plot = figure(title="Example of a vertical bar chart") 
plot.vbar(x=[1, 2, 3, 4, 5], top=y, width=0.5, color="#CAB2D6") 
output_file("vertical_bar.html", mode="inline") 
show(plot) 

我的建議是檢查您正在使用的背景虛化的版本,然後檢查包含在CSV文件中的數據,有可能是沒有在那裏。