Revision: 5272
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=5272&view=rev
Author: jdh2358
Date: 2008-05-26 10:04:38 -0700 (Mon, 26 May 2008)
Log Message:
-----------
added a line vertex selector widget
Modified Paths:
--------------
branches/v0_91_maint/lib/matplotlib/lines.py
Modified: branches/v0_91_maint/lib/matplotlib/lines.py
===================================================================
--- branches/v0_91_maint/lib/matplotlib/lines.py 2008-05-26 17:02:46 UTC (rev 5271)
+++ branches/v0_91_maint/lib/matplotlib/lines.py 2008-05-26 17:04:38 UTC (rev 5272)
@@ -1467,8 +1467,33 @@
class VertexSelector:
"""
manage the callbacks to maintain a list of selected vertices for
- matplotlib.lines.Lin2D. Derived classes should override
+ matplotlib.lines.Line2D. Derived classes should override
process_selected to do something with the picks
+
+ Here is an example which highlights the selected verts with red
+ circles::
+
+ import numpy as np
+ import matplotlib.pyplot as plt
+ import matplotlib.lines as lines
+
+ class HighlightSelected(lines.VertexSelector):
+ def __init__(self, line, fmt='ro', **kwargs):
+ lines.VertexSelector.__init__(self, line)
+ self.markers, = self.axes.plot([], [], fmt, **kwargs)
+
+ def process_selected(self, ind, xs, ys):
+ self.markers.set_data(xs, ys)
+ self.canvas.draw()
+
+ fig = plt.figure()
+ ax = fig.add_subplot(111)
+ x, y = np.random.rand(2, 30)
+ line, = ax.plot(x, y, 'bs-', picker=5)
+
+ selector = HighlightSelected(line)
+ plt.show()
+
"""
def __init__(self, line):
"""
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|