Set default line style loop in matplotlib

I can set the default color for the lines in matplotlib using matplotlib.rcParams['axes.color_cycle'] = my_color_list, but I cannot figure out how to do the same with line styles (i.e. '-','--','-.',':'). I know that I can install this using something like

linecycler = itertools.cycle(lines)
for i in range(n):
    plt.plot(x[i],y[i],next(linecycler))

but I would like to be able to do something more, as in the color cycle, so I don’t need to create a new bike every time I want to capture. How can i do this?

+4
source share
1 answer

matplotlib 1.5 , rcParam, axes.prop_cycle ( axes.color_cycle axes.prop_cycle). , - :

import matplotlib.pyplot as plt
from cycler import cycler
plt.rc('axes', prop_cycle=(cycler('color', ['r', 'g', 'b', 'y']) +
                           cycler('linestyle', ['-', '--', ':', '-.'])))

. .

+6

Source: https://habr.com/ru/post/1616675/


All Articles