|
From: <ef...@us...> - 2010-04-03 07:18:24
|
Revision: 8219
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=8219&view=rev
Author: efiring
Date: 2010-04-03 07:18:18 +0000 (Sat, 03 Apr 2010)
Log Message:
-----------
Axes.hist: add color kwarg.
Modified Paths:
--------------
trunk/matplotlib/lib/matplotlib/axes.py
Modified: trunk/matplotlib/lib/matplotlib/axes.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/axes.py 2010-04-02 21:29:38 UTC (rev 8218)
+++ trunk/matplotlib/lib/matplotlib/axes.py 2010-04-03 07:18:18 UTC (rev 8219)
@@ -7097,8 +7097,10 @@
*patches*) will be returned.
*color*:
+ Color spec or sequence of color specs, one per
+ dataset. Default (*None*) uses the standard line
+ color sequence.
-
kwargs are used to update the properties of the hist
:class:`~matplotlib.patches.Rectangle` instances:
@@ -7163,6 +7165,14 @@
nx = len(x) # number of datasets
+ if color is None:
+ color = [self._get_lines.color_cycle.next()
+ for i in xrange(nx)]
+ else:
+ color = mcolors.colorConverter.to_rgba_array(color)
+ if len(color) != nx:
+ raise ValueError("color kwarg must have one color per dataset")
+
if weights is not None:
if isinstance(w, np.ndarray):
w = np.array(weights)
@@ -7245,11 +7255,10 @@
else: # orientation == 'vertical'
_barfunc = self.bar
- for m in n:
- color = self._get_lines.color_cycle.next()
+ for m, c in zip(n, color):
patch = _barfunc(bins[:-1]+boffset, m, width, bottom,
align='center', log=log,
- color=color)
+ color=c)
patches.append(patch)
if stacked:
if bottom is None:
@@ -7277,20 +7286,19 @@
fill = (histtype == 'stepfilled')
- for m in n:
+ for m, c in zip(n, color):
y[1:-1:2], y[2::2] = m, m
if log:
y[y<1e-100]=1e-100
if orientation == 'horizontal':
x,y = y,x
- color = self._get_lines.color_cycle.next()
if fill:
patches.append( self.fill(x, y,
- closed=False, facecolor=color) )
+ closed=False, facecolor=c) )
else:
patches.append( self.fill(x, y,
- closed=False, edgecolor=color, fill=False) )
+ closed=False, edgecolor=c, fill=False) )
# adopted from adjust_x/ylim part of the bar method
if orientation == 'horizontal':
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|