|
From: Tony Yu <ts...@gm...> - 2012-07-25 21:11:26
|
On Wed, Jul 25, 2012 at 5:11 PM, Scott Henderson <st...@co...> wrote: > Hello, I'm trying to incorporate some matplotlib widgets into my scripts > that generate plots. I'm unsure why, but if I wrap the figure creation > lines in lasso_demo.py with a function the demo does not work. Why? > > #Original: > #------------ > if __name__ == '__main__': > data = [Datum(*xy) for xy in randn(100,2)] > fig = figure() > ax = fig.add_subplot(111, xlim=(0,1), ylim=(0,1), autoscale_on=False) > lman = LassoManager(ax, data) > show() > > #Change: > #------------ > def run(points): > data = [Datum(*xy) for xy in points] > fig = figure() > ax = fig.add_subplot(111, xlim=(0,1), ylim=(0,1), autoscale_on=False) > lman = LassoManager(ax, data) > show() > > if __name__ == '__main__': > points = rand(100, 2) > run(points) > > > -- > --------------- > Scott T. Henderson > http://www.geo.cornell.edu/eas/gstudent/sth54/contact.html > Your changes work fine on my system. Are you sure the example you wrote above is exactly the same as what you're running? For example, if I move the `show` out of the function and back into '__main__', then the lasso stops working (because the lasso manager gets garbage collected). Otherwise, I can't reproduce the issue. Actually, what did you mean by "does not work" (e.g., no lasso, error,)? -Tony |