Revision: 8265
          http://matplotlib.svn.sourceforge.net/matplotlib/?rev=8265&view=rev
Author:   efiring
Date:     2010-04-22 03:34:10 +0000 (Thu, 22 Apr 2010)

Log Message:
-----------
examples/cursor_demo: update to use axhline, axvline

Modified Paths:
--------------
    trunk/matplotlib/examples/pylab_examples/cursor_demo.py

Modified: trunk/matplotlib/examples/pylab_examples/cursor_demo.py
===================================================================
--- trunk/matplotlib/examples/pylab_examples/cursor_demo.py     2010-04-22 
03:22:55 UTC (rev 8264)
+++ trunk/matplotlib/examples/pylab_examples/cursor_demo.py     2010-04-22 
03:34:10 UTC (rev 8265)
@@ -15,22 +15,19 @@
 class Cursor:
     def __init__(self, ax):
         self.ax = ax
-        self.lx, = ax.plot( (0,0), (0,0), 'k-' )  # the horiz line
-        self.ly, = ax.plot( (0,0), (0,0), 'k-' )  # the vert line
+        self.lx = ax.axhline(color='k')  # the horiz line
+        self.ly = ax.axvline(color='k')  # the vert line
 
         # text location in axes coords
         self.txt = ax.text( 0.7, 0.9, '', transform=ax.transAxes)
 
     def mouse_move(self, event):
         if not event.inaxes: return
-        ax = event.inaxes
-        minx, maxx = ax.get_xlim()
-        miny, maxy = ax.get_ylim()
 
         x, y = event.xdata, event.ydata
         # update the line positions
-        self.lx.set_data( (minx, maxx), (y, y) )
-        self.ly.set_data( (x, x), (miny, maxy) )
+        self.lx.set_ydata(y )
+        self.ly.set_xdata(x )
 
         self.txt.set_text( 'x=%1.2f, y=%1.2f'%(x,y) )
         draw()
@@ -43,8 +40,8 @@
     """
     def __init__(self, ax, x, y):
         self.ax = ax
-        self.lx, = ax.plot( (0,0), (0,0), 'k-' )  # the horiz line
-        self.ly, = ax.plot( (0,0), (0,0), 'k-' )  # the vert line
+        self.lx = ax.axhline(color='k')  # the horiz line
+        self.ly = ax.axvline(color='k')  # the vert line
         self.x = x
         self.y = y
         # text location in axes coords
@@ -53,9 +50,6 @@
     def mouse_move(self, event):
 
         if not event.inaxes: return
-        ax = event.inaxes
-        minx, maxx = ax.get_xlim()
-        miny, maxy = ax.get_ylim()
 
         x, y = event.xdata, event.ydata
 
@@ -63,8 +57,8 @@
         x = self.x[indx]
         y = self.y[indx]
         # update the line positions
-        self.lx.set_data( (minx, maxx), (y, y) )
-        self.ly.set_data( (x, x), (miny, maxy) )
+        self.lx.set_ydata(y )
+        self.ly.set_xdata(x )
 
         self.txt.set_text( 'x=%1.2f, y=%1.2f'%(x,y) )
         print 'x=%1.2f, y=%1.2f'%(x,y)
@@ -81,3 +75,4 @@
 ax.plot(t, s, 'o')
 axis([0,1,-1,1])
 show()
+


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

------------------------------------------------------------------------------
_______________________________________________
Matplotlib-checkins mailing list
Matplotlib-checkins@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-checkins

Reply via email to