Increment matplotlib color cycle

后端 未结 3 1149
野趣味
野趣味 2021-02-20 14:43

Is there a simple way to increment the matplotlib color cycle without digging into axes internals?

When plotting interactively a common pattern I use is:



        
3条回答
  •  一生所求
    2021-02-20 15:10

    Similar to the other answers but using matplotlib color cycler:

    import matplotlib.pyplot as plt
    from itertools import cycle
    
    prop_cycle = plt.rcParams['axes.prop_cycle']
    colors = cycle(prop_cycle.by_key()['color'])
    for data in my_data:
        ax.plot(data.x, data.y, color=next(colors))
    

提交回复
热议问题