From: Jae-Joon L. <lee...@gm...> - 2009-10-02 19:07:53
|
On Fri, Oct 2, 2009 at 7:30 AM, rafa5 <rap...@ya...> wrote: > > I had to change the inset_locater.py file a little though. In your suggested > code below : > > axins1 = inset_axes(ax, width="100%", height="20%", > loc=3, borderpad=0, > axes_kwargs=dict(frameon=False) > ) > > the kwarg 'borderpad' was not doing anything because it was not being passed > to 'AnchoredSizeLocator', so there is a slightly modified version that works > for me attached that replaces the old one in > /usr/share/pyshared/mpl_toolkits/axes_grid > The attachment is missing. However, I think this is already fixed in the svn. http://matplotlib.svn.sourceforge.net/viewvc/matplotlib/trunk/matplotlib/lib/mpl_toolkits/axes_grid/inset_locator.py?view=diff&r1=7729&r2=7730 I should have checked whether my code works in the released version. Regards, -JJ > before anyone uses it maybe one of you more expereinced guys can say whether > it makes sense what I did. > > For the lineout along the y axis I just changed the width to 20% and the > height to 100% and always set the correct data limits by using > axins1.set_ylim( ymiin= ... , ymax= ...). > > Thanks again for your help :) > > Raphael > > > > Jae-Joon Lee wrote: >> >> 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 <rap...@ya...> >> 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 >>> Mat...@li... >>> 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 >> Mat...@li... >> https://lists.sourceforge.net/lists/listinfo/matplotlib-users >> >> > http://www.nabble.com/file/p25714268/inset_locator.py inset_locator.py > -- > View this message in context: http://www.nabble.com/placing-a-plot-on-top-of-an-imshow-tp25667058p25714268.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 > Mat...@li... > https://lists.sourceforge.net/lists/listinfo/matplotlib-users > |