Hi all,
I ran into a problem where I wanted to plot a step-plot with dashed lines instead of solid lines which can be important for print media. This isn't possible with the current matplotlib version, so I added support for this. The patch is attached, but I didn't commit it yet since I wanted to ask for feedback first. It basically adds support to do

pylab.plot(x, y, 'steps--')

to create a step plot with dashed lines.

mm




Index: lines.py
===================================================================
--- lines.py	(revision 6055)
+++ lines.py	(working copy)
@@ -561,11 +561,27 @@
         if linestyle not in self._lineStyles:
             if ls_mapper.has_key(linestyle):
                 linestyle = ls_mapper[linestyle]
-            else:
+            elif not linestyle.startswith('steps'):
                 verbose.report('Unrecognized line style %s, %s' %
                                             (linestyle, type(linestyle)))
         if linestyle in [' ','']:
             linestyle = 'None'
+        if linestyle.startswith('steps'):
+            stepslinestyle = linestyle[-2:]
+            if stepslinestyle=='--':
+                self._stepslineFunc = getattr(self, self._lineStyles['--'])
+                linestyle = linestyle[:-2]
+            elif stepslinestyle=='-.':
+                self._stepslineFunc = getattr(self, self._lineStyles['-.'])
+                linestyle = linestyle[:-2]
+            elif stepslinestyle[1]==':':
+                self._stepslineFunc = getattr(self, self._lineStyles[':'])
+                linestyle = linestyle[:-1]
+            elif stepslinestyle[1]=='-':
+                self._stepslineFunc = getattr(self, self._lineStyles['-'])
+                linestyle = linestyle[:-1]
+            else:
+                self._stepslineFunc = getattr(self, self._lineStyles['-'])
         self._linestyle = linestyle
         self._lineFunc = self._lineStyles[linestyle]
 
@@ -676,7 +692,7 @@
 
         path = Path(steps)
         path = path.transformed(self.get_transform())
-        self._draw_solid(renderer, gc, path, IdentityTransform())
+        self._stepslineFunc(renderer, gc, path, IdentityTransform())
 
 
     def _draw_steps_post(self, renderer, gc, path, trans):
@@ -688,7 +704,7 @@
 
         path = Path(steps)
         path = path.transformed(self.get_transform())
-        self._draw_solid(renderer, gc, path, IdentityTransform())
+        self._stepslineFunc(renderer, gc, path, IdentityTransform())
 
 
     def _draw_steps_mid(self, renderer, gc, path, trans):
@@ -703,7 +719,7 @@
 
         path = Path(steps)
         path = path.transformed(self.get_transform())
-        self._draw_solid(renderer, gc, path, IdentityTransform())
+        self._stepslineFunc(renderer, gc, path, IdentityTransform())
 
 
     def _draw_dashed(self, renderer, gc, path, trans):
-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
Matplotlib-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/matplotlib-devel

Reply via email to