Python 有没有办法在bokeh中自动设置颜色?

Python 有没有办法在bokeh中自动设置颜色?,python,bokeh,Python,Bokeh,在Bokeh中是否有一种方法可以自动为绘图中的每一行设置新颜色?类似于matlab中的“保持全部” from bokeh.plotting import figure x= [1,2,3,4,5] y = [1,2,3,4,5] p = figure() p.multi_line([x,x],[np.power(y,2),np.power(y,3)]) show(p) # I'd like all lines to automatically be a different color, or

在Bokeh中是否有一种方法可以自动为绘图中的每一行设置新颜色?类似于matlab中的“保持全部”

from bokeh.plotting import figure
x= [1,2,3,4,5]
y = [1,2,3,4,5]

p = figure()
p.multi_line([x,x],[np.power(y,2),np.power(y,3)])
show(p)
# I'd like all lines to automatically be a different color, or selected from a map

p = figure()
p.line(x,np.power(y,2))
p.line(x,np.power(y,3))
# And/or this to produce lines of different color

可以通过从调色板中选择颜色并为每个线图设置不同的颜色来完成:

from bokeh.palettes import Dark2_5 as palette
import itertools

#colors has a list of colors which can be used in plots 
colors = itertools.cycle(palette) 

p = figure()
p.line(x,np.power(y,2),color=colors[0])
p.line(x,np.power(y,3),color=colors[1]) 

谢谢我不得不将
colors[0]
更改为
next(colors)
,因为你不能索引一个循环对象:
p.line(x,np.power(y,2),color=next(colors))p.line(x,np.power(y,3),color=next(colors))