Bugfix for matplotlib.Axes.stem

Dear list,

There is a bug in stem, demonstrated by:

from matplotlib.pylab import *

stem(arange(10),arange(10),hold=False)
show()

A simple fix is below; it simply sets hold to True for the duration of
the stem method, and restores the hold state once done.

This was tested with the very simple

plot(arange(10)); stem(arange(10),arange(10),hold=True); show()

and

plot(arange(10)); stem(arange(10),arange(10),hold=False); show()

Regards,

Rory

Index: axes.py

···

===================================================================
--- axes.py (revision 2406)
+++ axes.py (working copy)
@@ -2509,7 +2509,10 @@
         http://www.mathworks.com/access/helpdesk/help/techdoc/ref/stem.html
         for details and examples/stem_plot.py for a demo.
         """
+ remember_hold=self._hold
         if not self._hold: self.cla()
+ self.hold(True)
+
         markerline, = self.plot(x, y, markerfmt)

         stemlines = []
@@ -2518,6 +2521,9 @@
             stemlines.append(l)

         baseline, = self.plot([amin(x), amax(x)], [0,0], basefmt)
+
+ self.hold(remember_hold)
+
         return markerline, stemlines, baseline

Rory,

I applied your patch to svn, revision 2408.

Thanks.

Eric

Rory Yorke wrote:

···

Dear list,

There is a bug in stem, demonstrated by:

from matplotlib.pylab import *

stem(arange(10),arange(10),hold=False)
show()

A simple fix is below; it simply sets hold to True for the duration of
the stem method, and restores the hold state once done.

This was tested with the very simple

plot(arange(10)); stem(arange(10),arange(10),hold=True); show()

and

plot(arange(10)); stem(arange(10),arange(10),hold=False); show()

Regards,

Rory

Index: axes.py

--- axes.py (revision 2406)
+++ axes.py (working copy)
@@ -2509,7 +2509,10 @@
         Plot discrete sequence data - MATLAB stem
         for details and examples/stem_plot.py for a demo.
         """
+ remember_hold=self._hold
         if not self._hold: self.cla()
+ self.hold(True)
+
         markerline, = self.plot(x, y, markerfmt)
          stemlines =
@@ -2518,6 +2521,9 @@
             stemlines.append(l)
          baseline, = self.plot([amin(x), amax(x)], [0,0], basefmt)
+
+ self.hold(remember_hold)
+
         return markerline, stemlines, baseline

-------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
matplotlib-users List Signup and Options