Bokeh - 在不同的地块绘制不同的颜色
Bokeh - Plot different colors in different plots
我正在尝试在不同的图中绘制不同批次的数据。我希望每批次的每一行都有不同的颜色。
这是我试过的:
color = 7
x = df['Time']
TOOLS = "crosshair, hover, reset, pan, save"
p = [figure(title="Title_1", x_axis_label='Elapsed Time (s)', y_axis_label='Voltage [V]', tools = TOOLS, x_range=(0, 100), y_range=(0, 1000)),
figure(title="Title_2", x_axis_label='Elapsed Time (s)', y_axis_label='Voltage [V]', tools = TOOLS, x_range=(0, 100), y_range=(0, 1000))]
for i in range(0,20):
p[0].line(x, df.iloc[:,i], line_color = Magma256[color][i])
for i in range(20,36):
p[1].line(x, df.iloc[:,i], line_color = Magma256[color][i])
plts = gridplot([p[0],p[1]], ncols = 1, plot_width = 1000, plot_height = 1000)
show(plts)
尝试此操作时出现以下错误:
IndexError: string index out of range
我认为这意味着我的
"line_color = Magma256[color][i]"
超出范围,但如果它有 256 大小怎么可能?我可以尝试什么?
所以我解决了。
显然我必须阅读更多关于它的内容。这是我使用的解释和解决方案。
代码中的一切都很好,问题是 Magma256
是一个列表。
我正在尝试将其用作目录。这意味着如果我想正确使用它,我必须放置 Directory[index of the list][index of the color inside the list]
例如Magma[256][1]
如果我想要 Magma256。
要用不同颜色绘制两个图中的所有线条,代码如下所示:
color = 256
for i in range(0,20):
p[0].line(x, df.iloc[:,i], line_color = Magma[color][i])
for i in range(20,36):
p[1].line(x, df.iloc[:,i], line_color = Magma[color][i])
我正在尝试在不同的图中绘制不同批次的数据。我希望每批次的每一行都有不同的颜色。
这是我试过的:
color = 7
x = df['Time']
TOOLS = "crosshair, hover, reset, pan, save"
p = [figure(title="Title_1", x_axis_label='Elapsed Time (s)', y_axis_label='Voltage [V]', tools = TOOLS, x_range=(0, 100), y_range=(0, 1000)),
figure(title="Title_2", x_axis_label='Elapsed Time (s)', y_axis_label='Voltage [V]', tools = TOOLS, x_range=(0, 100), y_range=(0, 1000))]
for i in range(0,20):
p[0].line(x, df.iloc[:,i], line_color = Magma256[color][i])
for i in range(20,36):
p[1].line(x, df.iloc[:,i], line_color = Magma256[color][i])
plts = gridplot([p[0],p[1]], ncols = 1, plot_width = 1000, plot_height = 1000)
show(plts)
尝试此操作时出现以下错误:
IndexError: string index out of range
我认为这意味着我的
"line_color = Magma256[color][i]"
超出范围,但如果它有 256 大小怎么可能?我可以尝试什么?
所以我解决了。
显然我必须阅读更多关于它的内容。这是我使用的解释和解决方案。
代码中的一切都很好,问题是 Magma256
是一个列表。
我正在尝试将其用作目录。这意味着如果我想正确使用它,我必须放置 Directory[index of the list][index of the color inside the list]
例如Magma[256][1]
如果我想要 Magma256。
要用不同颜色绘制两个图中的所有线条,代码如下所示:
color = 256
for i in range(0,20):
p[0].line(x, df.iloc[:,i], line_color = Magma[color][i])
for i in range(20,36):
p[1].line(x, df.iloc[:,i], line_color = Magma[color][i])