When plotting with Bokeh, how do you automatically cycle through a color pallette?

后端 未结 4 1566
别那么骄傲
别那么骄傲 2021-01-01 10:40

I want to use a loop to load and/or modify data and plot the result within the loop using Bokeh (I am familiar with Matplotlib\'s axes.color_cycle). Here is a simple exampl

4条回答
  •  南方客
    南方客 (楼主)
    2021-01-01 10:57

    In Python > 3.7 you could do something like this:

    from bokeh.palettes import Category10_10
           
    color = Category10_10.__iter__()
    
    p.line(x, y1, line_width=2, color=next(color))
    

    This will cycle through each element of the list until exhausted each time you use next().

    Every sequence type in python can return an iterator object.

提交回复
热议问题