2017-07-28 25 views
0

我想添加抖動到一個情節,以便重複的值不重疊對方和代碼運行良好,但顯示HTML文件給我一個錯誤。散景抖動不起作用

代碼:

from bokeh.plotting import figure 
from bokeh.io import output_file, show 
from bokeh.models import ColumnDataSource, Jitter 

x = [1,2,3,4,5,3,3,3] 
y = [1,2,2,4,5,2,3,3] 

data = ColumnDataSource(dict(x=x, y=y)) 

output_file("iris.html") 

f=figure() 

f.plot_width = 800 
f.plot_height = 800 
f.sizing_mode="stretch_both" 

f.circle(x={'value': "x", 'transform': Jitter(width=0.4)}, y="y", source=data) 

show(f) 

當我打開HTML文件,我得到的錯誤是:

Bokeh Error 
Number property 'x' given invalid value: "x" 

回答

1

這不是一個很大的錯誤消息,但問題是你想變換值「x」而不是數據源的字段「x」。它應該工作:

f.circle(x={'field': "x", 'transform': Jitter(width=0.4)}, y="y", source=data) 
+0

謝謝!這解決了它。 – Tony