Sophie

Sophie

distrib > Mandriva > 2010.2 > i586 > media > contrib-backports > by-pkgid > a44f8c7e78ee9c5838c1fb080c9e7630 > files > 1079

python-matplotlib-doc-1.1.1-1mdv2010.1.noarch.rpm

.. _api-color_cycle:

api example code: color_cycle.py
================================



.. plot:: /home/mandrake/rpm/BUILD/matplotlib-1.1.1/doc/mpl_examples/api/color_cycle.py

::

    """
    Illustrate the API for changing the cycle of colors used
    when plotting multiple lines on a single Axes.
    """
    
    import numpy as np
    import matplotlib.pyplot as plt
    import matplotlib as mpl
    
    yy = np.arange(24)
    yy.shape = 6,4
    
    mpl.rc('lines', linewidth=4)
    
    fig = plt.figure()
    mpl.rcParams['axes.color_cycle'] = ['r', 'g', 'b', 'c']
    ax = fig.add_subplot(2,1,1)
    ax.plot(yy)
    ax.set_title('Changed default color cycle to rgbc')
    
    ax = fig.add_subplot(2,1,2)
    ax.set_color_cycle(['c', 'm', 'y', 'k'])
    ax.plot(yy)
    ax.set_title('This axes only, cycle is cmyk')
    
    plt.show()
    
    
    

Keywords: python, matplotlib, pylab, example, codex (see :ref:`how-to-search-examples`)