散景-具有分类值的多线图

时间:2020-02-01 18:42:56

标签: python pandas bokeh

我正在使用此数据框:

enter image description here

我正在尝试使用Bokeh生成多行绘图,其中['Joined']为x值:

# Split columns for multi-line plot
x = df['Joined'].tolist()
y1 = df['Mean_value'].tolist()
y2 = df['Median_value'].tolist()

# Set Figure and Plot

p = figure(height=600, width=900, toolbar_location=None, x_range=x)

p.multi_line([x, y1], [x, y2], color=['#CE1141', '#06BB6'], alpha=[0.54, 0.40], line_width=3)

现在就给我这个:

enter image description here

我可以通过绘制单独的线条来获得所需的结果,但这使HoverTool的使用非常复杂。

有什么想法吗?

谢谢!

1 个答案:

答案 0 :(得分:1)

您以错误的方式将值传递给方法。第一个参数为xs,应包含所有 x 系列,但 not 任意 y 系列。不过,您正在传递[x, y1]的{​​{1}},这将绘制xs的值作为第二行的x坐标。您可能打算这样做:

y1