Can you just reuse the ax1 for plotting? I guess that might be the easiest way.
With imshow, the location of ax1 is determined at the drawing time, therefore you need a way to adjust the location of ax2 after this happens. Doing this manually requires some internal knowledge of mpl. If you use 0.99 and later, you can use axes_grid toolkits. Here is an example code. import matplotlib.pyplot as plt from mpl_toolkits.axes_grid.inset_locator import inset_axes fig = plt.figure(1, [5.5, 3]) ax = fig.add_subplot(1,1,1) ax.set_aspect(1.) axins1 = inset_axes(ax, width="100%", height="20%", loc=3, borderpad=0, axes_kwargs=dict(frameon=False) ) axins1.xaxis.set_visible(False) axins1.yaxis.set_visible(False) axins1.plot([0, 0.5, 1], [0,1,0]) plt.show() See here for more details. http://matplotlib.sourceforge.net/mpl_toolkits/axes_grid/users/overview.html One thing to note, the current design of mpl does not allow you to share axis when aspect is set(i.e., w/ imshow) (or you have to have adjustable="datalim"), although there is a way to do it with axes_grid. Regards, -JJ On Wed, Sep 30, 2009 at 1:50 AM, rafa5 <raphaelwolfg...@yahoo.co.nz> wrote: > > Hi guys, > > I'm having problems creating a plot. I attached a crude version that I drew > with Gimp to show what I actually want to do with matplotlib > http://www.nabble.com/file/p25667058/example2.png example2.png . Basically > it boils down to placing an axes instance on top of an existing axes with an > imshow already on it. In the end I would like to have a kind of lineout of > the values of the array of the imshow along an x=constant & y=constant line. > So my pathetic (and unsuccesful attempt) is something like: > > import matplotlib.pyplot as p > fig = p.figure(1) > > ax1_box = [0.1, 0.1, 0.5, 0.5] > ax2_box = [0.1, 0.1, 0.5, 0.1] > > ax1 = fig.add_axes( ax1_box ) > ax1.imshow(data) > > ax2 = fig.add_axes( ax2_box, frameon=False) > ax2.plot( data[5 , :] ) #lineout of 6th row for > example > p.setp(ax2b, xticks=[], yticks=[]) > > > My problems: > as I don't want to add axis labels ax2 data plot is wider than ax1 data > plot. > when i resize the window ax1 and ax2 move relative to another. > I hope it's possible to also do the lineput along the vertical (y) axis. > I'm too stupid to figure this out myself. > > Thanks a lot in advance for any suggestions :) > > Raphael > -- > View this message in context: > http://www.nabble.com/placing-a-plot-on-top-of-an-imshow-tp25667058p25667058.html > Sent from the matplotlib - users mailing list archive at Nabble.com. > > > ------------------------------------------------------------------------------ > Come build with us! The BlackBerry® Developer Conference in SF, CA > is the only developer event you need to attend this year. Jumpstart your > developing skills, take BlackBerry mobile applications to market and stay > ahead of the curve. Join us from November 9-12, 2009. Register now! > http://p.sf.net/sfu/devconf > _______________________________________________ > Matplotlib-users mailing list > Matplotlib-users@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/matplotlib-users > ------------------------------------------------------------------------------ Come build with us! The BlackBerry® Developer Conference in SF, CA is the only developer event you need to attend this year. Jumpstart your developing skills, take BlackBerry mobile applications to market and stay ahead of the curve. Join us from November 9-12, 2009. Register now! http://p.sf.net/sfu/devconf _______________________________________________ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users