use matplotlib color map for color cycle

后端 未结 3 489
夕颜
夕颜 2020-11-30 05:29

If I create colors by e.g:

import numpy as np
from matplotlib import pyplot as plt

n = 6
color = plt.cm.coolwarm(np.linspace(0.1,0.9,n))
color
3条回答
  •  攒了一身酷
    2020-11-30 05:49

    For Matplotlib 2.2, using the cycler module will do the trick, without the need to convert to Hex values.

    import cycler
    
    n = 100
    color = pyplot.cm.viridis(np.linspace(0, 1,n))
    mpl.rcParams['axes.prop_cycle'] = cycler.cycler('color', color)
    

提交回复
热议问题