ginput in nbagg backend to use in IPython Notebooks

nbagg is always running in the IPython event loop (as I understand it), so I am not sure how to integrate that with the blocking.

On the 1.4.x/master branch we have support for (almost, one PR still pending) all mouse and keyboard events so all of the mpl widgets should work (big thanks to Steven Silvester). T

What do you want to use that relies on ginput?

You can fake up a non-blocking version something like:

from collections import deque


class accumulator(object):

def __init__(self, n=5):

self.list_of_points = deque(maxlen=n)

def on_event(self, event):

self.list_of_points.append(event)

import matplotlib

import itertools

import numpy as np

matplotlib.use('nbagg')

import matplotlib.pyplot as plt

plt.close('all')

fig, ax = plt.subplots()

x = np.linspace(0,10,10000)

y = np.sin(x)

ln, = ax.plot(x,y)

dd = accumulator(15)

fig.canvas.mpl_connect('button_press_event', dd.on_event)

plt.show()

and then get the points by


dd.lest_of_points

This code obviously needs lots of bells and whistles, but points in the right direction.

Tom

···

On Mon Jan 26 2015 at 2:45:45 PM Mark Bakker <markbak@…552…149…> wrote:

Hello List,

Are there any plans to make ginput work in the nbagg backend?

It would be so cool if I could use that in an IPython Notebook together with the other widgets.

Thanks,

Mark


Dive into the World of Parallel Programming. The Go Parallel Website,

sponsored by Intel and developed in partnership with Slashdot Media, is your

hub for all things parallel software development, from weekly thought

leadership blogs to news, videos, case studies, tutorials and more. Take a

look and join the conversation now. http://goparallel.sourceforge.net/_______________________________________________

Matplotlib-devel mailing list

Matplotlib-devel@…1041…sourceforge.net

https://lists.sourceforge.net/lists/listinfo/matplotlib-devel