Doc suggestion

All,

The linebuilder program on: http://matplotlib.sourceforge.net/users/event_handling.html

Needs two extra lines, one at the beginning and one at the end. Their absence, particularly the second one, can cause confusion.

import matplotlib.pyplot as plt

class LineBuilder:

def init(self, line):

self.line = line

self.xs = list(line.get_xdata())

self.ys = list(line.get_ydata())

self.cid = line.figure.canvas.mpl_connect(‘button_press_event’, self)

def call(self, event):

print ‘click’, event

if event.inaxes!=self.line.axes: return

self.xs.append(event.xdata)

self.ys.append(event.ydata)

self.line.set_data(self.xs, self.ys)

self.line.figure.canvas.draw()

fig = plt.figure()

ax = fig.add_subplot(111)

ax.set_title(‘click to build line segments’)

line, = ax.plot([0], [0]) # empty line

linebuilder = LineBuilder(line)

plt.show()

Thanks. That's a good suggestion. It's been applied to SVN, and will make it on to the website the next time the website is updated.

Mike

David Arnold wrote:

···

All,

The linebuilder program on: http://matplotlib.sourceforge.net/users/event_handling.html

Needs two extra lines, one at the beginning and one at the end. Their absence, particularly the second one, can cause confusion.

import matplotlib.pyplot as plt

class LineBuilder:
    def __init__(self, line):
        self.line = line
        self.xs = list(line.get_xdata())
        self.ys = list(line.get_ydata())
        self.cid = line.figure.canvas.mpl_connect('button_press_event', self)

    def __call__(self, event):
        print 'click', event
        if event.inaxes!=self.line.axes: return
        self.xs.append(event.xdata)
        self.ys.append(event.ydata)
        self.line.set_data(self.xs, self.ys)
        self.line.figure.canvas.draw()

fig = plt.figure()
ax = fig.add_subplot(111)
ax.set_title('click to build line segments')
line, = ax.plot([0], [0]) # empty line
linebuilder = LineBuilder(line)

plt.show()

------------------------------------------------------------------------

------------------------------------------------------------------------------
Download Intel® Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
------------------------------------------------------------------------

_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
matplotlib-users List Signup and Options
  
--
Michael Droettboom
Science Software Branch
Operations and Engineering Division
Space Telescope Science Institute
Operated by AURA for NASA