Revision: 6631
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=6631&view=rev
Author: jdh2358
Date: 2008-12-16 16:54:10 +0000 (Tue, 16 Dec 2008)
Log Message:
-----------
added markevery property to Line2D
Modified Paths:
--------------
trunk/matplotlib/CHANGELOG
trunk/matplotlib/doc/users/pyplot_tutorial.rst
trunk/matplotlib/lib/matplotlib/lines.py
trunk/matplotlib/unit/nose_tests.py
Modified: trunk/matplotlib/CHANGELOG
===================================================================
--- trunk/matplotlib/CHANGELOG 2008-12-16 16:19:21 UTC (rev 6630)
+++ trunk/matplotlib/CHANGELOG 2008-12-16 16:54:10 UTC (rev 6631)
@@ -1,3 +1,6 @@
+2008-12-16 Added markevery property to Line2D to support subsampling
+ of markers - JDH
+
2008-12-15 Removed mpl_data symlink in docs. On platforms that do not
support symlinks, these become copies, and the font files
are large, so the distro becomes unneccessarily bloaded.
Modified: trunk/matplotlib/doc/users/pyplot_tutorial.rst
===================================================================
--- trunk/matplotlib/doc/users/pyplot_tutorial.rst 2008-12-16 16:19:21 UTC
(rev 6630)
+++ trunk/matplotlib/doc/users/pyplot_tutorial.rst 2008-12-16 16:54:10 UTC
(rev 6631)
@@ -117,6 +117,7 @@
markeredgewidth or mew float value in points
markerfacecolor or mfc any matplotlib color
markersize or ms float
+markevery None | integer | (startind, stride)
picker used in interactive line selection
pickradius the line pick selection radius
solid_capstyle ['butt' | 'round' | 'projecting']
Modified: trunk/matplotlib/lib/matplotlib/lines.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/lines.py 2008-12-16 16:19:21 UTC (rev
6630)
+++ trunk/matplotlib/lib/matplotlib/lines.py 2008-12-16 16:54:10 UTC (rev
6631)
@@ -177,6 +177,7 @@
solid_joinstyle = None,
pickradius = 5,
drawstyle = None,
+ markevery = None,
**kwargs
):
"""
@@ -226,6 +227,7 @@
self.set_linewidth(linewidth)
self.set_color(color)
self.set_marker(marker)
+ self.set_markevery(markevery)
self.set_antialiased(antialiased)
self.set_markersize(markersize)
self._dashSeq = None
@@ -320,6 +322,32 @@
"""
self.pickradius = d
+
+ def set_markevery(self, every):
+ """
+ Set the markevery property to subsample the plot when using
+ markers. Eg if ``markevery=5``, every 5-th marker will be
+ plotted. *every* can be
+
+ None
+ Every point will be plotted
+
+ an integer N
+ Every N-th marker will be plotted starting with marker 0
+
+ A length-2 tuple of integers
+ every=(start, N) will start at point start and plot every N-th
marker
+
+
+ ACCEPTS: None | integer | (startind, stride)
+
+ """
+ self._markevery = every
+
+ def get_markevery(self):
+ 'return the markevery setting'
+ return self._markevery
+
def set_picker(self,p):
"""Sets the event picker details for the line.
@@ -472,6 +500,19 @@
funcname = self._markers.get(self._marker, '_draw_nothing')
if funcname != '_draw_nothing':
tpath, affine =
self._transformed_path.get_transformed_points_and_affine()
+
+ # subsample the markers if markevery is not None
+ markevery = self.get_markevery()
+ if markevery is not None:
+ if iterable(markevery):
+ startind, stride = markevery
+ else:
+ startind, stride = 0, markevery
+ if tpath.codes is not None:
+ tpath.codes = tpath.codes[startind::stride]
+ tpath.vertices = tpath.vertices[startind::stride]
+
+
markerFunc = getattr(self, funcname)
markerFunc(renderer, gc, tpath, affine.frozen())
Modified: trunk/matplotlib/unit/nose_tests.py
===================================================================
--- trunk/matplotlib/unit/nose_tests.py 2008-12-16 16:19:21 UTC (rev 6630)
+++ trunk/matplotlib/unit/nose_tests.py 2008-12-16 16:54:10 UTC (rev 6631)
@@ -1,3 +1,5 @@
+import numpy as np
+
import nose, nose.tools as nt
import numpy.testing as nptest
@@ -3,5 +5,4 @@
import matplotlib
matplotlib.use('Agg')
-import numpy as np
import matplotlib.pyplot as plt
import matplotlib.axes as maxes
@@ -11,7 +12,32 @@
fig = plt.figure()
ax = maxes.Subplot(fig, 1, 1, 1)
fig.add_subplot(ax)
+ plt.close(fig)
+def test_markevery():
+ x, y = np.random.rand(2, 100)
+
+ # check marker only plot
+ fig = plt.figure()
+ ax = fig.add_subplot(111)
+ ax.plot(x, y, 'o')
+ ax.plot(x, y, 'd', markevery=None)
+ ax.plot(x, y, 's', markevery=10)
+ ax.plot(x, y, '+', markevery=(5, 20))
+ fig.canvas.draw()
+ plt.close(fig)
+
+ # check line/marker combos
+ fig = plt.figure()
+ ax = fig.add_subplot(111)
+ ax.plot(x, y, '-o')
+ ax.plot(x, y, '-d', markevery=None)
+ ax.plot(x, y, '-s', markevery=10)
+ ax.plot(x, y, '-+', markevery=(5, 20))
+ fig.canvas.draw()
+ plt.close(fig)
+
if __name__=='__main__':
nose.runmodule(argv=['-s','--with-doctest'], exit=False)
- pass
+
+ plt.show()
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
------------------------------------------------------------------------------
SF.Net email is Sponsored by MIX09, March 18-20, 2009 in Las Vegas, Nevada.
The future of the web can't happen without you. Join us at MIX09 to help
pave the way to the Next Web now. Learn more and register at
http://ad.doubleclick.net/clk;208669438;13503038;i?http://2009.visitmix.com/
_______________________________________________
Matplotlib-checkins mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/matplotlib-checkins