Revision: 6071
          http://matplotlib.svn.sourceforge.net/matplotlib/?rev=6071&view=rev
Author:   efiring
Date:     2008-09-06 21:37:53 +0000 (Sat, 06 Sep 2008)

Log Message:
-----------
Add star marker to Line2D and plot

Modified Paths:
--------------
    trunk/matplotlib/CHANGELOG
    trunk/matplotlib/examples/pylab_examples/line_styles.py
    trunk/matplotlib/lib/matplotlib/axes.py
    trunk/matplotlib/lib/matplotlib/lines.py

Modified: trunk/matplotlib/CHANGELOG
===================================================================
--- trunk/matplotlib/CHANGELOG  2008-09-05 15:37:01 UTC (rev 6070)
+++ trunk/matplotlib/CHANGELOG  2008-09-06 21:37:53 UTC (rev 6071)
@@ -1,3 +1,5 @@
+2008-09-06 Added 5-point star marker to plot command - EF
+
 2008-09-05 Fix hatching in PS backend - MGD
 
 2008-09-03 Fix log with base 2 - MGD

Modified: trunk/matplotlib/examples/pylab_examples/line_styles.py
===================================================================
--- trunk/matplotlib/examples/pylab_examples/line_styles.py     2008-09-05 
15:37:01 UTC (rev 6070)
+++ trunk/matplotlib/examples/pylab_examples/line_styles.py     2008-09-06 
21:37:53 UTC (rev 6071)
@@ -1,26 +1,36 @@
 #!/usr/bin/env python
-from pylab import *
+# This should probably be replaced with a demo that shows all
+# line and marker types in a single panel, with labels.
 
-t = arange(0.0, 3.0, 0.05)
-s = sin(2*pi*t)
-styles = ('-', '--', ':', '.', 'o', '^', 'v', '<', '>', 's', '+')
+import matplotlib.pyplot as plt
+from matplotlib.lines import Line2D
+import numpy as np
+
+t = np.arange(0.0, 1.0, 0.1)
+s = np.sin(2*np.pi*t)
+linestyles = ['_', '-', '--', ':']
+markers = []
+for m in Line2D.markers:
+    try:
+        if len(m) == 1 and m != ' ':
+            markers.append(m)
+    except TypeError:
+        pass
+
+styles = linestyles + markers
+
 colors = ('b', 'g', 'r', 'c', 'm', 'y', 'k')
 
 
 axisNum = 0
 for row in range(5):
-    for col in range(4):
-        s = sin(2*pi*t)
+    for col in range(5):
         axisNum += 1
-        subplot(5,4,axisNum)
+        ax = plt.subplot(5, 5, axisNum)
         style = styles[axisNum % len(styles) ]
         color = colors[axisNum % len(colors) ]
-        plot(t,s, style + color)
-        # turn off the ticklabels if not first row or first col
-        if not gca().is_first_col():
-            setp(gca(), 'yticklabels', [])
-        if not gca().is_last_row():
-            setp(gca(), 'xticklabels', [])
+        plt.plot(t,s, style + color, markersize=10)
+        ax.set_yticklabels([])
+        ax.set_xticklabels([])
 
-#savefig('line_styles', dpi=300)
-show()
+plt.show()

Modified: trunk/matplotlib/lib/matplotlib/axes.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/axes.py     2008-09-05 15:37:01 UTC (rev 
6070)
+++ trunk/matplotlib/lib/matplotlib/axes.py     2008-09-06 21:37:53 UTC (rev 
6071)
@@ -3030,6 +3030,7 @@
             >     # triangle right symbols
             s     # square symbols
             +     # plus symbols
+            *     # star symbols
             x     # cross symbols
             D     # diamond symbols
             d     # thin diamond symbols

Modified: trunk/matplotlib/lib/matplotlib/lines.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/lines.py    2008-09-05 15:37:01 UTC (rev 
6070)
+++ trunk/matplotlib/lib/matplotlib/lines.py    2008-09-06 21:37:53 UTC (rev 
6071)
@@ -99,6 +99,7 @@
         '4'  : '_draw_tri_right',
         's'  : '_draw_square',
         'p'  : '_draw_pentagon',
+        '*'  : '_draw_star',
         'h'  : '_draw_hexagon1',
         'H'  : '_draw_hexagon2',
         '+'  : '_draw_plus',
@@ -120,7 +121,8 @@
         '' : '_draw_nothing',
     }
 
-    filled_markers = ('o', '^', 'v', '<', '>', 's', 'd', 'D', 'h', 'H', 'p')
+    filled_markers = ('o', '^', 'v', '<', '>',
+                        's', 'd', 'D', 'h', 'H', 'p', '*')
 
     zorder = 2
     validCap = ('butt', 'round', 'projecting')
@@ -573,7 +575,7 @@
         """
         Set the line marker
 
-        ACCEPTS: [ '+' | ',' | '.' | '1' | '2' | '3' | '4'
+        ACCEPTS: [ '+' | '*' | ',' | '.' | '1' | '2' | '3' | '4'
                  | '<' | '>' | 'D' | 'H' | '^' | '_' | 'd'
                  | 'h' | 'o' | 'p' | 's' | 'v' | 'x' | '|'
                  | TICKUP | TICKDOWN | TICKLEFT | TICKRIGHT
@@ -815,7 +817,15 @@
         renderer.draw_markers(gc, Path.unit_regular_polygon(5), transform,
                               path, path_trans, rgbFace)
 
+    def _draw_star(self, renderer, gc, path, path_trans):
+        offset = 0.5 * renderer.points_to_pixels(self._markersize)
+        transform = Affine2D().scale(offset)
+        rgbFace = self._get_rgb_face()
+        _starpath = Path.unit_regular_star(5, innerCircle=0.381966)
+        renderer.draw_markers(gc, _starpath, transform,
+                              path, path_trans, rgbFace)
 
+
     def _draw_hexagon1(self, renderer, gc, path, path_trans):
         offset = 0.5 * renderer.points_to_pixels(self._markersize)
         transform = Affine2D().scale(offset)


This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.

-------------------------------------------------------------------------
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-checkins mailing list
Matplotlib-checkins@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-checkins

Reply via email to