ginput in nbagg backend to use in IPython Notebooks

I would keep an eye on scikit-image and their viewer work. One of the drivers behind Steven working on the nbagg backend was prep work to port their imageviewer code over to using nbagg from than qt.

I think it is also possible to interact between ipython widgets and figure/axes objects with nbagg.

Tom

···

On Tue Jan 27 2015 at 12:20:32 PM Eric Firing <efiring@…229…> wrote:

On 2015/01/27 6:51 AM, Mark wrote:

ginput works fine in a GUI window, but there is no matplotlib widget

where I can type text or numbers in a box. Like the FloatTextWidget in

IPython. Or am I missing something?

I think you are correct. John Hunter explicitly avoided the temptation

to keep adding backend-independent widgets to mpl; we have a hard enough

time trying to maintain and improve the plotting capabilities without

trying to turn mpl into a wxwidgets work-alike. If you need more than

the very minimal widgets presently on offer, you have to choose a gui

toolkit and use it directly, embedding matplotlib in it.

Eric

Sent from my iPhone

On Jan 27, 2015, at 17:34, Paul Hobson <pmhobson@…149… > > > mailto:pmhobson@...149...> wrote:

I’m 99% sure you can do this in a GUI window. Does your solution have

to be in the notebook?

On Tue, Jan 27, 2015 at 12:37 AM, Mark Bakker <markbak@…149… > > >> mailto:markbak@...149...> wrote:

Thanks, Tom.
I want to use ginput to draw a straight line on a graph.
The line is used to select a cross-section of a contour plot.
I was afraid it wasn't going to be easy.
Getting to it from the other side, is there a matplotlib widget in
the works where I can type text or numbers in a box? Like
the FloatTextWidget in IPython?
Problem is I want to make a small GUI that includes both a text
widget (which is available in IPython) and a 'select points in
graph' widget like ginput in matplotlib.
Mark
On Mon, Jan 26, 2015 at 11:47 PM, Thomas Caswell >  > >>     <tcaswell@...149... <mailto:tcaswell@...149...>> wrote:
    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@...149... <mailto:markbak@...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/](http://goparallel.sourceforge.net/)
_______________________________________________
Matplotlib-devel mailing list
Matplotlib-devel@...1041...sourceforge.net
<mailto:Matplotlib-devel@lists.sourceforge.net>
[https://lists.sourceforge.net/lists/listinfo/matplotlib-devel](https://lists.sourceforge.net/lists/listinfo/matplotlib-devel)

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


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