Hi,okay, I have added a keyword 'where' as suggested. I also now changed the way the incoming data is converted. I took this from the axes.pie() function. I don't know much about the unit types yet :-(
Concerning masked arrays: Do I have to consider something special there? Manuel Ted Drain wrote:
At 10:36 AM 8/14/2007, Eric Firing wrote:Ted Drain wrote:Manuel,We do plots like this all the time. One thing we've found that's nice to have is a keyword that controls when the increase in y happens. We use a step style keyword that can be 'pre' (go up then right), 'post' (go right then up), and 'mid' (right 0.5, up, right 0.5).Good idea.Regarding your patch, you might want to check other areas in MPL for data processing examples. I could be wrong but I'm not sure you can assume that incoming data is a float. Some of the unit conversion examples or the line collection code might have better examples.Incoming data can be any numeric type, but it ends up getting converted to the default float type (not float32) internally.Whenever possible, it is good to support masked array input.Agreed - but the way the patch was written, I don't think it will support anything but float (especially not the unit types).EricTed At 07:59 AM 8/14/2007, Manuel Metz wrote:Hi,I have created a patch against latest svn that adds a function step to the axes class to plot step-functions ;-) It's really simple but nice ... Any interest in adding this?Manuel Index: axes.py =================================================================== --- axes.py (revision 3709) +++ axes.py (working copy) @@ -4995,6 +4995,18 @@ steps=[1, 2, 5, 10], integer=True)) return im + + def step(self, x, y, *args, **kwargs): + x2 = npy.zeros((2*len(x)), npy.float32) + y2 = npy.zeros((2*len(x)), npy.float32) + + x2[0::2] = x + x2[1::2] = x + + y2[1::2] = y + y2[2::2] = y[:-1] + + self.plot(x2, y2, *args, **kwargs) class SubplotBase: """-------------------------------------------------------------------------This SF.net email is sponsored by: Splunk Inc. Still grepping through log files to find problems? Stop. Now Search log events and configuration files using AJAX and a browser. Download your FREE copy of Splunk now >> http://get.splunk.com/ _______________________________________________ Matplotlib-devel mailing list Matplotlib-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-devel-------------------------------------------------------------------------------------------------------------------------------------------------This SF.net email is sponsored by: Splunk Inc. Still grepping through log files to find problems? Stop. Now Search log events and configuration files using AJAX and a browser. Download your FREE copy of Splunk now >> http://get.splunk.com/ ------------------------------------------------------------------------ _______________________________________________ Matplotlib-devel mailing list Matplotlib-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-devel------------------------------------------------------------------------ ------------------------------------------------------------------------- This SF.net email is sponsored by: Splunk Inc. Still grepping through log files to find problems? Stop. Now Search log events and configuration files using AJAX and a browser. Download your FREE copy of Splunk now >> http://get.splunk.com/ ------------------------------------------------------------------------ _______________________________________________ Matplotlib-devel mailing list Matplotlib-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-devel
Index: axes.py =================================================================== --- axes.py (revision 3709) +++ axes.py (working copy) @@ -4995,6 +4995,45 @@ steps=[1, 2, 5, 10], integer=True)) return im + + def step(self, x, y, *args, **kwargs): + + where = kwargs.pop('where', 'pre') + + if not iterable(x): x = npy.asarray([x]).astype(npy.float32) + else: x = npy.asarray(x).astype(npy.float32) + + if not iterable(y): x = npy.asarray([y]).astype(npy.float32) + else: y = npy.asarray(y).astype(npy.float32) + + x2 = npy.zeros((2*len(x)), npy.float32) + y2 = npy.zeros((2*len(y)), npy.float32) + + if where=='pre': + x2[0::2] = x + x2[1::2] = x + + y2[0::2] = y + y2[1:-1:2] = y[1:] + y2[-1] = y[-1] + elif where=='post': + x2[0] = x[0] + x2[1:-1:2] = x[1:] + x2[2::2] = x[1:] + x2[-1] = x[-1] + + y2[0::2] = y + y2[1::2] = y + elif where=='mid': + x2[0] = x[0] + x2[1:-1:2] = 0.5*(x[:-1]+x[1:]) + x2[2::2] = 0.5*(x[:-1]+x[1:]) + x2[-1] = x[-1] + + y2[0::2] = y + y2[1::2] = y + + self.plot(x2, y2, *args, **kwargs) class SubplotBase: """
<<inline: stepplot.png>>
from numpy import * import pylab as P x = arange(1.,10.) y = arange(1.,10.) x[4]+=0.5 fig = P.figure() ax = fig.gca() ax.step(x,y, where='post') y += 1. ax.step(x,y,where='pre') y += 1.5 ax.step(x,y,where='mid') P.xlim(0,10) P.ylim(-1,13) P.show()
------------------------------------------------------------------------- This SF.net email is sponsored by: Splunk Inc. Still grepping through log files to find problems? Stop. Now Search log events and configuration files using AJAX and a browser. Download your FREE copy of Splunk now >> http://get.splunk.com/
_______________________________________________ Matplotlib-devel mailing list Matplotlib-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-devel