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
答案 0 :(得分:2)
可以通过从调色板中选择颜色并为每个线图设置不同来完成:
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])