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).

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.

Ted

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

Reply via email to