Click/Item detection

Hi all,

I would like to be able to click on a small plot in a panel and bring that up bigger in a new panel. The idea here is that the small plots are subplots and clicking on them will bring them “in focus” so the user can better manipulate the plot properties. What would be the best way to go about doing that? I have the two panels set up but no click event detection currently going on. Attached is a screen shot of the general gist of what I am going for. I am using wxPython and matplotlib.

I apologize if this is far too vague and I will try to specify further if needed.

Josh

Screen shot 2012-07-11 at 4.55.33 PM.png

Hi,

Hi all,

I would like to be able to click on a small plot in a panel and bring that
up bigger in a new panel. The idea here is that the small plots are subplots
and clicking on them will bring them "in focus" so the user can better
manipulate the plot properties. What would be the best way to go about doing
that? I have the two panels set up but no click event detection currently
going on. Attached is a screen shot of the general gist of what I am going
for. I am using wxPython and matplotlib.

I apologize if this is far too vague and I will try to specify further if
needed.

You will probably have to handle it through matplotlib. If the plot on
the top right is one of your subplots, you may want to connect a
matplotlib mouse event listener to it (pseudo-code):

import matplotlib
matplotlib.use('WXAgg')
from matplotlib.backends.backend_wxagg import FigureCanvasWxAgg
from matplotlib.figure import Figure

self.figure = Figure()
self.canvas = FigureCanvasWxAgg(self, -1, self.figure)
self.canvas.mpl_connect('button_press_event', self.OnClick)

self.my_small_subplot = self.figure.add_subplot(3, 1, 1)

# Small plots drawing...

def OnClick(self, event):

    if event.inaxes == self.my_small_subplot:
        self.DrawOnBigPlot()

You will have to figure out how to pass your data from the small
subplot to the big one (but that's relatively easy by looking at what
kind of data is contained in your small subplot lines), and you may
also want to keep the axes limits in sync between the small and the
big subplots.

···

On 11 July 2012 22:55, jskoeh9 wrote:

--
Andrea.

"Imagination Is The Only Weapon In The War Against Reality."
http://xoomer.alice.it/infinity77/

# ------------------------------------------------------------- #
def ask_mailing_list_support(email):

    if mention_platform_and_version() and include_sample_app():
        send_message(email)
    else:
        install_malware()
        erase_hard_drives()
# ------------------------------------------------------------- #

That’s perfect thank you!

···

On Wednesday, July 11, 2012 4:55:16 PM UTC-4, jskoeh9 wrote:

Hi all,

I would like to be able to click on a small plot in a panel and bring that up bigger in a new panel. The idea here is that the small plots are subplots and clicking on them will bring them “in focus” so the user can better manipulate the plot properties. What would be the best way to go about doing that? I have the two panels set up but no click event detection currently going on. Attached is a screen shot of the general gist of what I am going for. I am using wxPython and matplotlib.

I apologize if this is far too vague and I will try to specify further if needed.

Josh

If there were a fixed set of subplots but the plots themselves were to change dynamically, what is the best way to detect which subplot the mouse is over?

Josh

···

On Wednesday, July 11, 2012 4:55:16 PM UTC-4, jskoeh9 wrote:

Hi all,

I would like to be able to click on a small plot in a panel and bring that up bigger in a new panel. The idea here is that the small plots are subplots and clicking on them will bring them “in focus” so the user can better manipulate the plot properties. What would be the best way to go about doing that? I have the two panels set up but no click event detection currently going on. Attached is a screen shot of the general gist of what I am going for. I am using wxPython and matplotlib.

I apologize if this is far too vague and I will try to specify further if needed.

Josh

You will have to keep track of the various small subplots by saving a
reference to them as an attribute, although there might be another way
to do it (which I do not know, and it will probably be more
convoluted).

Please do not top post.

···

On 12 July 2012 20:37, jskoeh9 wrote:

If there were a fixed set of subplots but the plots themselves were to
change dynamically, what is the best way to detect which subplot the mouse
is over?

--
Andrea.

"Imagination Is The Only Weapon In The War Against Reality."
http://xoomer.alice.it/infinity77/

# ------------------------------------------------------------- #
def ask_mailing_list_support(email):

    if mention_platform_and_version() and include_sample_app():
        send_message(email)
    else:
        install_malware()
        erase_hard_drives()
# ------------------------------------------------------------- #

I’m not sure if I’d approach it this way (drawing plots on the “thumbnail buttons”). You can use a wx.BitmapButton over on the side that keeps an updated thumbnail of the real plot. To keep the thumbnail updated, hook into the matplotlib ‘draw_event’, (see mpl_connect), and save off the bitmap for the display each time. You can resize the full-size bitmap down to a thumbnail with PIL, I believe.

This way, your button on the right is always a small version of the real plot, and not an attempt to redraw the same plot on a tiny canvas, which always makes it look funny.

···

On Wednesday, July 11, 2012 4:55:16 PM UTC-4, jskoeh9 wrote:

Hi all,

I would like to be able to click on a small plot in a panel and bring that up bigger in a new panel. The idea here is that the small plots are subplots and clicking on them will bring them “in focus” so the user can better manipulate the plot properties. What would be the best way to go about doing that? I have the two panels set up but no click event detection currently going on. Attached is a screen shot of the general gist of what I am going for. I am using wxPython and matplotlib.

I apologize if this is far too vague and I will try to specify further if needed.

Josh

Thanks for the suggestion. I will take a look into that option later on as I am sure it does retain the image fidelity much better than the “squished” images of the subplots.

···

On Friday, July 13, 2012 12:44:34 PM UTC-4, dhyams wrote:

I’m not sure if I’d approach it this way (drawing plots on the “thumbnail buttons”). You can use a wx.BitmapButton over on the side that keeps an updated thumbnail of the real plot. To keep the thumbnail updated, hook into the matplotlib ‘draw_event’, (see mpl_connect), and save off the bitmap for the display each time. You can resize the full-size bitmap down to a thumbnail with PIL, I believe.

This way, your button on the right is always a small version of the real plot, and not an attempt to redraw the same plot on a tiny canvas, which always makes it look funny.

On Wednesday, July 11, 2012 4:55:16 PM UTC-4, jskoeh9 wrote:

Hi all,

I would like to be able to click on a small plot in a panel and bring that up bigger in a new panel. The idea here is that the small plots are subplots and clicking on them will bring them “in focus” so the user can better manipulate the plot properties. What would be the best way to go about doing that? I have the two panels set up but no click event detection currently going on. Attached is a screen shot of the general gist of what I am going for. I am using wxPython and matplotlib.

I apologize if this is far too vague and I will try to specify further if needed.

Josh