2017-03-22 54 views
0

我正在使用Jupyter Notebook來運行我的Python代碼。我的代碼的問題是輸出給出了一個空白圖(而不是來自Python的任何錯誤消息)。我製作散景圖的Python代碼給出了空白圖

我的代碼立場如下:

from bokeh.layouts import row 
from bokeh.plotting import figure, show, output_file 

data = myBenchmarkData 
factors = ["Group"] 
x = ["Rate"] 

dot = figure(title="Categorical Dot Plot", tools="", toolbar_location=None, 
     y_range=factors, x_range=[0,200]) 

dot.segment(0, factors, x, factors, line_width=2, line_color="green",) 
dot.circle(x, factors, size=15, fill_color="orange", line_color="green", line_width=3,) 

output_file("categorical.html", title="categorical.py example") 
show(row(dot, sizing_mode="scale_width")) 

當我運行這些一堆代碼,它不正確地創建一個新的HTML文件執行,但該頁面顯示與所提到的詞「集團」空白地塊y軸。 我的數據來自csv文件,並且它已正確導入。 「組」和「比率」是我的數據框中的一系列(列名)。

我做了一個測試,並硬編碼了因素和x的列表,並且情節工作正常。看來我的代碼並不理解我想要從「數據框」的「組」列中檢索因子列表,並從數據框的「速率」列中檢索x列表。

+0

是否有瀏覽器的JavaScript控制檯中的任何錯誤訊息? – bigreddot

+0

我該如何檢查? – user3115933

+0

http://webmasters.stackexchange.com/questions/8525/how-to-open-the-javascript-console-in-different-browsers – bigreddot

回答

0

有時很難解決您的實際數據問題,並且最好創建一些簡單的示例數據。此作品至少在背景虛化的版本,我使用的是0.12.4

from bokeh.layouts import row 
from bokeh.plotting import figure, show 
from bokeh.io import output_notebook 

output_notebook() 

x = [60,50,75,150,100] 
factors = ["cars","buses","airplanes","trains","bicycles"] 

dot = figure(title="Categorical Dot Plot", tools="", toolbar_location=None, 
     y_range=factors, x_range=[0,204]) 
dot.segment(0, factors, x, factors, line_width=2, line_color="green",) 
dot.circle(x, factors, size=15, fill_color="orange", line_color="green", line_width=3,) 

show(row(dot, sizing_mode="scale_width")) 

enter image description here

+0

@ user3115933我創建了一個僅使用5個對象的簡單示例。我正在使用散景版本0.12.4。我不知道這是不是在以前的版本,但它總是很好知道你使用的是什麼版本。 –