Index: examples/boxplot_demo.py
===================================================================
RCS file: /cvsroot/matplotlib/matplotlib/examples/boxplot_demo.py,v
retrieving revision 1.1
diff -u -r1.1 boxplot_demo.py
--- examples/boxplot_demo.py	29 Mar 2005 03:18:21 -0000	1.1
+++ examples/boxplot_demo.py	23 Nov 2005 16:24:57 -0000
@@ -4,58 +4,65 @@
 # Example boxplot code
 #
 
-from pylab import *
+import matplotlib
+import matplotlib.numerix as nx
+import pylab
+
+rand = nx.ra.random
 
 # fake up some data
 spread= rand(50) * 100
-center = ones(25) * 50
+center = nx.ones(25) * 50
 flier_high = rand(10) * 100 + 100
 flier_low = rand(10) * -100 
-data =concatenate((spread, center, flier_high, flier_low), 0)
+data = nx.concatenate((spread, center, flier_high, flier_low), 0)
 
-# basic plot
-boxplot(data)
-#savefig('box1')
-
-# notched plot
-figure()
-boxplot(data,1)
-#savefig('box2')
-
-# change outlier point symbols
-figure()
-boxplot(data,0,'gD')
-#savefig('box3')
-
-# don't show outlier points
-figure()
-boxplot(data,0,'')
-#savefig('box4')
-
-# horizontal boxes
-figure()
-boxplot(data,0,'rs',0)
-#savefig('box5')
-
-# change whisker length
-figure()
-boxplot(data,0,'rs',0,0.75)
-#savefig('box6')
+# we will use nine subplots
+fig = pylab.figure()
+subplot = 1
+def newplot(title):
+    global fig, subplot
+    ax = fig.add_subplot(3,3,subplot)
+    ax.set_title(title)
+    subplot += 1
+    return ax
+
+newplot('basic plot').boxplot(data)
+newplot('notched plot').boxplot(data,1)
+newplot('changed outlier symbols').boxplot(data,0,'gD')
+newplot('invisible outliers').boxplot(data,0,'')
+
+ax = newplot('horizontal')
+ax.boxplot(data,0,'rs',0)
+ax.set_xticks([])
+
+ax = newplot('changed whisker lengths')
+ax.boxplot(data,0,'rs',0,0.75)
+ax.set_xticks([])
 
 # fake up some more data
 spread= rand(50) * 100
-center = ones(25) * 40
+center = nx.ones(25) * 40
 flier_high = rand(10) * 100 + 100
 flier_low = rand(10) * -100 
-d2 = concatenate( (spread, center, flier_high, flier_low), 0 )
+d2 = nx.concatenate( (spread, center, flier_high, flier_low), 0 )
 data.shape = (-1, 1)
 d2.shape = (-1, 1)
-data = concatenate( (data, d2), 1 )
+data = nx.concatenate( (data, d2), 1 )
+
+newplot('multiple boxes').boxplot(data)
+
+ax = newplot('positions and widths')
+ax.boxplot(nx.concatenate( (data, 2*data), 1 ),
+           positions=[1,2,4,8], widths=[0.5,0.5,1,4])
+
+lines = newplot('line attributes').boxplot(data)
+pylab.setp(lines['medians'], color='green', linewidth=2)
+pylab.setp(lines['boxes'], linestyle='--')
+pylab.setp(lines['caps'], linewidth=2)
+pylab.setp(lines['whiskers'], linestyle='-', color='red')
+pylab.setp(lines['fliers'], marker='.')
 
-# multiple box plots on one figure
-figure()
-boxplot(data)
-#savefig('box7')
+pylab.show()
 
-show()
 
Index: lib/matplotlib/axes.py
===================================================================
RCS file: /cvsroot/matplotlib/matplotlib/lib/matplotlib/axes.py,v
retrieving revision 1.148
diff -u -r1.148 axes.py
--- lib/matplotlib/axes.py	16 Nov 2005 17:18:44 -0000	1.148
+++ lib/matplotlib/axes.py	23 Nov 2005 16:24:58 -0000
@@ -1042,8 +1042,8 @@
         """
         if not self._hold: self.cla()
         holdStatus = self._hold
-        lines = []
         x = asarray(x)
+        whiskers, caps, boxes, medians, fliers = [], [], [], [], []
 
         # if we've got a vector, reshape it
         rank = len(x.shape)
@@ -1057,7 +1057,7 @@
             positions = range(1, col + 1)
         if widths is None:
             distance = max(positions) - min(positions)
-            widths = distance * min(0.15, 0.5/distance)
+            widths = min(0.15*max(distance,1.0), 0.5)
         if isinstance(widths, float) or isinstance(widths, int):
             widths = ones((col,), 'd') * widths
 
@@ -1128,29 +1128,25 @@
                 med_x = [cap_x_min, cap_x_max]
                 med_y = [med, med]
 
-            # make a vertical plot . . .
-            if 1 == vert:
-                l = self.plot(wisk_x, [q1, wisk_lo], 'b--',
-                              wisk_x, [q3, wisk_hi], 'b--',
-                              cap_x, [wisk_hi, wisk_hi], 'k-',
-                              cap_x, [wisk_lo, wisk_lo], 'k-',
-                              box_x, box_y, 'b-',
-                              med_x, med_y, 'r-',
-                              flier_hi_x, flier_hi, sym,
-                              flier_lo_x, flier_lo, sym )
-                lines.extend(l)
-            # or perhaps a horizontal plot
+            # vertical or horizontal plot?
+            if vert:
+                def doplot(*args):
+                    return self.plot(*args)
             else:
-                l = self.plot([q1, wisk_lo], wisk_x, 'b--',
-                              [q3, wisk_hi], wisk_x, 'b--',
-                              [wisk_hi, wisk_hi], cap_x, 'k-',
-                              [wisk_lo, wisk_lo], cap_x, 'k-',
-                              box_y, box_x, 'b-',
-                              med_y, med_x, 'r-',
-                              flier_hi, flier_hi_x, sym,
-                              flier_lo, flier_lo_x, sym )
-                lines.extend(l)
-
+                def doplot(*args):
+                    shuffled = []
+                    for i in range(0, len(args), 3):
+                        shuffled.extend([args[i+1], args[i], args[i+2]])
+                    return self.plot(*shuffled)
+
+            whiskers.extend(doplot(wisk_x, [q1, wisk_lo], 'b--',
+                                   wisk_x, [q3, wisk_hi], 'b--'))
+            caps.extend(doplot(cap_x, [wisk_hi, wisk_hi], 'k-',
+                               cap_x, [wisk_lo, wisk_lo], 'k-'))
+            boxes.extend(doplot(box_x, box_y, 'b-'))
+            medians.extend(doplot(med_x, med_y, 'r-'))
+            fliers.extend(doplot(flier_hi_x, flier_hi, sym,
+                                 flier_lo_x, flier_lo, sym))
 
         # fix our axes/ticks up a little
         if 1 == vert:
@@ -1165,7 +1161,8 @@
         # reset hold status
         self.hold(holdStatus)
 
-        return lines
+        return dict(whiskers=whiskers, caps=caps, boxes=boxes,
+                    medians=medians, fliers=fliers)
 
     def barh(self, x, y, height=0.8, left=0,
             color='b', yerr=None, xerr=None, ecolor='k', capsize=3
