I want to create an copy of a subplot in its unique figure after being clicked 
on in a figure with multiple subplots.  My code seems to work but I believe is 
inefficient and I'd like to understand how to use the event.* information more 
effectively in mpl.

I am successfully creating multiple subplots in a Figure using a class with 
lines for the data such as below.  I create a new figure for each instance of 
the class with 8 subplots in each.
        
exec("self.a.plot(glbl.%s0_pcdata,glbl.%s6_pcdata,glbl.%s0_pcdata,glbl.%s9_pcdata)"%(color,color,color,color))

Furthermore I am using a mpl_connect to successfully capture and then validate 
which instance of the Figure for each of the unique subplots clicked on.
        self.cid=self.canvas.mpl_connect('button_press_event', click)

I want to use the event to make an alternate sized plot of the subplot chosen.  
I can do this through some modest logic where I use the event information 
identify the instance clicked on.  A partial description of this logic is below 
- which seems to work properly. (a, b, c ... are subplots;  Instances are 
Kfigure, Yfigure etc...)
def click(event):
    print 'you clicked x,y', event.x, event.y
    print 'you clicked inaxes', event.inaxes
    print 'string name of event', event.name
    print 'figure canvas instance', event.canvas
    if event.canvas==Kfigure.canvas:
        print "K canvas clicked"
    if event.canvas==Yfigure.canvas:
        print "Y canvas clicked"
    if event.inaxes==Kfigure.a:
        print "clicked inside subplot a of figure K" 

However, to create an alternate "new" plot of the subplot I clicked, I have to 
create extended logic code (as above) for each of 40 subplots on 5 figures, and 
then reidentify the source data similar to the original exec line and shown 
below.  This seems inefficient.  Isn't there a more straightforward way to 
create the subplot clicked in its instances of "new" figure  // sorry if my 
terminology is inexact.. noob // A section of my suspected inefficient code is 
below.

Isn't there a way to use the event.inaxes, or other axes or data information to 
identify the data to be plotted and then subplot it?  Ideally this should 
include legend information that was created with the instance as well - that is 
not explicitly shown but I have done.  All I am really trying to do is enlarge 
one of the subplots for the user.  In the example in this email, I simply want 
to have a large Kfigure.a created.

I can get my code to work but it seems overly long and inefficient.

 if event.inaxes==Kfigure.a:
        print "clicked inside subplot a of figure K"
        color="K"
        bigroot=Tk.Tk()
        bigroot.wm_title("title with big wm_title")
        bigf=Figure(figsize=(3,6), dpi=72)
        biga=bigf.add_subplot(111)
        exec("biga.plot(glbl.%s0_pcdata,glbl.%s6_pcdata)"%(color,color))
        bigcanvas=FigureCanvasTkAgg(bigf, master=bigroot)
        bigcanvas.show()
        bigcanvas.get_tk_widget().pack(side=Tk.TOP,fill=Tk.BOTH,expand=1)


      
____________________________________________________________________________________
Looking for last minute shopping deals?  
Find them fast with Yahoo! Search.  
http://tools.search.yahoo.com/newsearch/category.php?category=shopping
-------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://ad.doubleclick.net/clk;164216239;13503038;w?http://sf.net/marketplace
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users

Reply via email to