def update(attrname, old, new):
new_selected, new_x_factors, new_y_factors = get_subset(dictionary_selector.value, dictionary_selector.value)
bins = np.linspace(new_selected.counts.min(), new_selected.counts.max(), 10) # bin labels must be one more than len(colorpalette)
new_selected["color"] = pd.cut(new_selected.counts, bins, labels = list(reversed(palettes.Blues9)), include_lowest=True)
new_selected["wikidataID"] = new_selected["x"].map(lambda x: wikidataIDs.get(x))
fig.xaxis.axis_label = dictionary_selector.value
fig.yaxis.axis_label = dictionary_selector.value
fig.title.text = "Top %d fact co-occurrences selected" % top_n.value
src = ColumnDataSource(dict(
x=new_selected["x"].astype(object),
y=new_selected["y"].astype(object),
color=new_selected["color"].astype(object),
wikidataID=new_selected["wikidataID"],
counts=new_selected["counts"].astype(int),
raw=new_selected["raw"].astype(int)))
source.data.update(src.data)
fig.x_range.update(factors=new_x_factors[:top_n.value])
fig.y_range.update(factors=new_y_factors[:top_n.value])
评论列表
文章目录