当我通过(来自 Bokeh)绘制我的数据时rect()
,我在可视化中得到了一条奇异的水平块线。数据打印正确,据我所知格式正确(type()
验证它们都是列表)。任何人都可以诊断这个吗?如果问题不在这里,那么我可以附加更多代码。
(如果需要:在 Ubuntu 14.04 上运行 Python 2.7.6)
from bokeh.plotting import *
from bokeh.objects import HoverTool, ColumnDataSource
output_notebook()
#All the same color just for testing
colors = [
"#191919", "#191919", "#191919", "#191919", "#191919",
"#191919", "#191919", "#191919", "#191919", "#191919",
"#191919", "#191919", "#191919", "#191919", "#191919",
"#191919", "#191919", "#191919", "#191919", "#191919",
"#191919", "#191919", "#191919", "#191919", "#191919"
]
x_2 = []
for i in trans_dat: x_2.append(i)
y_2 = []
for i in trans_dat.index: y_2.append(i)
colors_2 = []
kwordxstate_2 = []
for y in y_2:
for x in x_2:
kword_state = trans_dat[x][y]
kwordxstate_2.append(kword_state)
colors_2.append(colors[kword_state])
source = ColumnDataSource(
data = dict(
x_2=x_2,
y_2=y_2,
colors_2=colors_2,
kwordxstate_2=kwordxstate_2,
)
)
rect(x_2, y_2, 1,1, source=source,
x_range=x_2, y_range=y_2,
color=colors_2, line_color=None,
tools="resize,hover,previewsave", title="Keywords by state",
plot_width=900, plot_height=400)
grid().grid_line_color = None
axis().axis_line_color = None
axis().major_tick_line_color = None
axis().major_label_text_font_size = "10pt"
axis().major_label_standoff = 0
xaxis().location = "top"
xaxis().major_label_orientation = np.pi/3
show()