Revision: 8066
          http://matplotlib.svn.sourceforge.net/matplotlib/?rev=8066&view=rev
Author:   efiring
Date:     2010-01-04 02:22:26 +0000 (Mon, 04 Jan 2010)

Log Message:
-----------
Added rcParams['axes.color_cycle']

Modified Paths:
--------------
    trunk/matplotlib/CHANGELOG
    trunk/matplotlib/doc/api/api_changes.rst
    trunk/matplotlib/examples/api/color_cycle.py
    trunk/matplotlib/lib/matplotlib/axes.py
    trunk/matplotlib/lib/matplotlib/rcsetup.py
    trunk/matplotlib/matplotlibrc.template

Modified: trunk/matplotlib/CHANGELOG
===================================================================
--- trunk/matplotlib/CHANGELOG  2010-01-03 21:07:05 UTC (rev 8065)
+++ trunk/matplotlib/CHANGELOG  2010-01-04 02:22:26 UTC (rev 8066)
@@ -1,3 +1,5 @@
+2010-01-03 Added rcParams['axes.color_cycle'] - EF
+
 2010-01-03 Added Pierre's qt4 formlayout editor and toolbar button - JDH
 
 2009-12-31 Add support for using math text as marker symbols (Thanks to tcb)

Modified: trunk/matplotlib/doc/api/api_changes.rst
===================================================================
--- trunk/matplotlib/doc/api/api_changes.rst    2010-01-03 21:07:05 UTC (rev 
8065)
+++ trunk/matplotlib/doc/api/api_changes.rst    2010-01-04 02:22:26 UTC (rev 
8066)
@@ -10,7 +10,11 @@
 Changes beyond 0.99.x
 =====================
 
-* You can now print several figures to one pdf file and modify the 
+* There is a new rc parameter ``axes.color_cycle``, and the color
+  cycle is now independent of the rc parameter ``lines.color``.
+  :func:`matplotlib.Axes.set_default_color_cycle` is deprecated.
+
+* You can now print several figures to one pdf file and modify the
   document information dictionary of a pdf file. See the docstrings
   of the class :class:`matplotlib.backends.backend_pdf.PdfPages` for
   more information.

Modified: trunk/matplotlib/examples/api/color_cycle.py
===================================================================
--- trunk/matplotlib/examples/api/color_cycle.py        2010-01-03 21:07:05 UTC 
(rev 8065)
+++ trunk/matplotlib/examples/api/color_cycle.py        2010-01-04 02:22:26 UTC 
(rev 8066)
@@ -13,7 +13,7 @@
 mpl.rc('lines', linewidth=4)
 
 fig = plt.figure()
-mpl.axes.set_default_color_cycle(['r', 'g', 'b', 'c'])
+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')

Modified: trunk/matplotlib/lib/matplotlib/axes.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/axes.py     2010-01-03 21:07:05 UTC (rev 
8065)
+++ trunk/matplotlib/lib/matplotlib/axes.py     2010-01-04 02:22:26 UTC (rev 
8066)
@@ -1,5 +1,7 @@
 from __future__ import division, generators
 import math, sys, warnings, datetime, new
+from operator import itemgetter
+import itertools
 
 import numpy as np
 from numpy import ma
@@ -31,7 +33,6 @@
 import matplotlib.ticker as mticker
 import matplotlib.transforms as mtransforms
 
-from operator import itemgetter
 
 iterable = cbook.iterable
 is_string_like = cbook.is_string_like
@@ -115,12 +116,19 @@
     :class:`Axes` to which it will apply; it will
     apply to all future axes.
 
-    *clist* is a sequence of mpl color specifiers
+    *clist* is a sequence of mpl color specifiers.
 
+    See also: :meth:`~matplotlib.axes.Axes.set_color_cycle`.
+
+    .. Note:: Deprecated 2010/01/03.
+              Set rcParams['axes.color_cycle'] directly.
+
     """
-    _process_plot_var_args.defaultColors = clist[:]
-    rcParams['lines.color'] = clist[0]
+    rcParams['axes.color_cycle'] = clist
+    warnings.warn("Set rcParams['axes.color_cycle'] directly",
+                                                    DeprecationWarning)
 
+
 class _process_plot_var_args:
     """
 
@@ -134,42 +142,18 @@
 
     an arbitrary number of *x*, *y*, *fmt* are allowed
     """
-
-    defaultColors = ['b','g','r','c','m','y','k']
     def __init__(self, axes, command='plot'):
         self.axes = axes
         self.command = command
-        self._clear_color_cycle()
+        self.set_color_cycle()
 
-    def _clear_color_cycle(self):
-        self.colors = _process_plot_var_args.defaultColors[:]
-        # if the default line color is a color format string, move it up
-        # in the que
-        try:
-            ind = self.colors.index(rcParams['lines.color'])
-        except ValueError:
-            self.firstColor = rcParams['lines.color']
-        else:
-            self.colors[0], self.colors[ind] = self.colors[ind], self.colors[0]
-            self.firstColor = self.colors[0]
+    def set_color_cycle(self, clist=None):
+        if clist is None:
+            clist = rcParams['axes.color_cycle']
+        self._colors = itertools.cycle(clist)
 
-        self.Ncolors = len(self.colors)
-
-        self.count = 0
-
-    def set_color_cycle(self, clist):
-        self.colors = clist[:]
-        self.firstColor = self.colors[0]
-        self.Ncolors = len(self.colors)
-        self.count = 0
-
     def _get_next_cycle_color(self):
-        if self.count==0:
-            color = self.firstColor
-        else:
-            color = self.colors[int(self.count % self.Ncolors)]
-        self.count += 1
-        return color
+        return self._colors.next()
 
     def __call__(self, *args, **kwargs):
 
@@ -907,9 +891,10 @@
         """
         Set the color cycle for any future plot commands on this Axes.
 
-        clist is a list of mpl color specifiers.
+        *clist* is a list of mpl color specifiers.
         """
         self._get_lines.set_color_cycle(clist)
+        self._get_patches_for_fill.set_color_cycle(clist)
 
 
     def ishold(self):

Modified: trunk/matplotlib/lib/matplotlib/rcsetup.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/rcsetup.py  2010-01-03 21:07:05 UTC (rev 
8065)
+++ trunk/matplotlib/lib/matplotlib/rcsetup.py  2010-01-04 02:22:26 UTC (rev 
8066)
@@ -207,6 +207,14 @@
 
     raise ValueError('%s does not look like a color arg%s'%(s, msg))
 
+def validate_colorlist(s):
+    'return a list of colorspecs'
+    if type(s) is str:
+        return [validate_color(c.strip()) for c in s.split(',')]
+    else:
+        assert type(s) in [list, tuple]
+        return [validate_color(c) for c in s]
+
 def validate_stringlist(s):
     'return a list'
     if type(s) is str:
@@ -440,6 +448,9 @@
                                # of the axis range is smaller than the
                                # first or larger than the second
     'axes.unicode_minus'        : [True, validate_bool],
+    'axes.color_cycle'      : [['b','g','r','c','m','y','k'],
+                                    validate_colorlist], # cycle of plot
+                                                         # line colors
 
     'polaraxes.grid'        : [True, validate_bool],   # display polar grid or 
not
     'axes3d.grid'           : [True, validate_bool],   # display 3d grid

Modified: trunk/matplotlib/matplotlibrc.template
===================================================================
--- trunk/matplotlib/matplotlibrc.template      2010-01-03 21:07:05 UTC (rev 
8065)
+++ trunk/matplotlib/matplotlibrc.template      2010-01-04 02:22:26 UTC (rev 
8066)
@@ -161,11 +161,11 @@
 #text.markup         : 'plain'  # Affects how text, such as titles and labels, 
are
                                 # interpreted by default.
                                 # 'plain': As plain, unformatted text
-                               # 'tex': As TeX-like text.  Text between $'s 
will be
-                               # formatted as a TeX math expression.
-                               # This setting has no effect when text.usetex 
is True.
-                               # In that case, all text will be sent to TeX for
-                               # processing.
+                                # 'tex': As TeX-like text.  Text between $'s 
will be
+                                # formatted as a TeX math expression.
+                                # This setting has no effect when text.usetex 
is True.
+                                # In that case, all text will be sent to TeX 
for
+                                # processing.
 
 #text.hinting : True # If True, text will be hinted, otherwise not.  This only
                      # affects the Agg backend.
@@ -184,8 +184,8 @@
 #mathtext.fontset : cm # Should be 'cm' (Computer Modern), 'stix',
                        # 'stixsans' or 'custom'
 #mathtext.fallback_to_cm : True  # When True, use symbols from the Computer 
Modern
-                                # fonts when a symbol can not be found in one 
of
-                                # the custom math fonts.
+                                 # fonts when a symbol can not be found in one 
of
+                                 # the custom math fonts.
 
 #mathtext.default : it # The default font to use for math.
                        # Can be any of the LaTeX font names, including
@@ -211,6 +211,10 @@
                                # first or larger than the second
 #axes.unicode_minus  : True    # use unicode for the minus symbol
                                # rather than hypen.  See 
http://en.wikipedia.org/wiki/Plus_sign#Plus_sign
+#axes.color_cycle    : b, g, r, c, m, y, k  # color cycle for plot lines
+                                            # as list of string colorspecs:
+                                            # single letter, long name, or
+                                            # web-style hex
 
 #polaraxes.grid      : True    # display grid on polar axes
 #axes3d.grid         : True    # display grid on 3d axes


This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.

------------------------------------------------------------------------------
This SF.Net email is sponsored by the Verizon Developer Community
Take advantage of Verizon's best-in-class app development support
A streamlined, 14 day to market process makes app distribution fast and easy
Join now and get one step closer to millions of Verizon customers
http://p.sf.net/sfu/verizon-dev2dev 
_______________________________________________
Matplotlib-checkins mailing list
Matplotlib-checkins@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-checkins

Reply via email to