## matplotlib-users

 [Matplotlib-users] matlab-like "children" of axes? From: jules hummon - 2006-07-02 20:09:53 ```Hello all My specific question is this: Suppose I have a figure, with an axes object, and an XY plot: #------- import matplotlib import pylab as P t = P.arange(0.0,1.0,0.02) x = P.sin(2*P.pi*t) y = P.exp(-t*3.)*P.cos(3*P.pi*t) ff = P.Figure(figsize=(5,4), dpi=100) ss = P.subplot(222) pp = ss.plot(x,y,'.-') # some program resets x,y limits P.show() #----- (Sorry for my matlab-tainted language): I would like to use ff.gca() to get the handle of the active axes object (which should be ss) and then determine the indices into the original data (x,y) which reflect the points showing in the current axis limits (whatever they have been set to) Is there any way to - find the axes objects that count "ff" as their parent? - access the x,y points as "children" of the axes object ss? I may be approaching my larger goal the wrong way, but I am still interested in this question. Thanks, Jules ```
 Re: [Matplotlib-users] matlab-like "children" of axes? From: PGM - 2006-07-02 21:00:18 ```Jules, > > ff = P.Figure(figsize=(5,4), dpi=100) > ss = P.subplot(222) > pp = ss.plot(x,y,'.-') > > # some program resets x,y limits > P.show() > #----- > Is there any way to > - find the axes objects that count "ff" as their parent? The `figure` associated with a subplot object `ss` is `ss.figure` The list of axes objects associated with a figure `ff` is ff.axes. So, you should be able to access the subplots as ss.figure.axes > - access the x,y points as "children" of the axes object ss? Try something like pp.get_xdata(), pp.get_ydata() where pp is the output of ss.plot IMHO, it'd be easier to go: ff = P.figure() ss = ff.add_subplot(222) pp = ss.plot(x,y,'.-') You can check that id(ff.axes[0])==id(ss) Now, if you have several subplots in the same figure, with one line per subplot, you should consider creating a list where you'd store the output of subplot.plot. That way, you'd just have to parse the list to recvoer the xdata and ydata For example ff = P.figure() plotlines = [] ss = ff.add_subplot(222) plotlines.append(ss.plot(x,y)) ```