【发布时间】:2017-12-27 09:39:14
【问题描述】:
您好,我有以下数据:
month_id class count
201612 B 69
201612 G 54
201612 P 31
201612 S 42
201612 V 89
201612 Other 77
201701 B 87
201701 G 79
201701 P 96
201701 S 68
201701 V 08
201701 Other 653
201702 B 67
201702 G 82
201702 P 60
201702 S 46
201702 V 96
201702 Other 72
201703 B 94
201703 G 62
201703 P 95
现在我想通过折线图显示每个班级的计数如何在 month_id 中变化。如下所示。
因此,x 轴将包含月份 ID,每个类将有 6 行,y 轴将用于计数。我的数据在 df2 中。
我尝试过以下操作:
# Create new column to make plotting easier
df2['class_date'] = df2['class'] + "-" + df2['month_id'].map(str)
# x and y axes
class_date = df2['class_date'].tolist()
count = df2['count'].tolist()
# Bokeh's mapping of column names and data lists
numlines=len(df2.class.unique())
mypalette=Spectral11[0:numlines]
plot = figure(plot_width= 800 , plot_height=350)
plot.multi_line(xs= [class_date]*numlines , ys=[count],
line_color=mypalette,line_width= 3)
show(plot)
但是这给了我以下错误:
Bokeh Error
Cannot read property 'length' of undefined
有人可以帮我解决这个问题吗?
【问题讨论】: