From: Brad M. <bra...@gm...> - 2011-09-20 17:29:16
|
Hi Ben, Thanks. Using label_outer() does, as you say, only show labels on the edge and that is something I wanted to do. It doesn't, however, make a common y-axis label and a common x-axis label (instead there are now 2 of each, instead of 4). It appears that I might be able to add a common y and x label by brute-forcing the labels with text, along the lines of something like: fig.text(0.5,0.04,'common xlabel',ha='center',va='center') fig.text(0.00,0.5,'common > ylabel',ha='center',va='center',rotation='vertical') Now I just need to play with spacing and change precise ticklabels and I'll be able to finish this plot up! Thanks everyone, Brad On Tue, Sep 20, 2011 at 9:12 AM, Benjamin Root <ben...@ou...> wrote: > > > On Tue, Sep 20, 2011 at 11:06 AM, Brad Malone <bra...@gm...>wrote: > >> Hi Jeffrey, >> >> Thanks the response. Sorry about the term "global axis". That was clearly >> not the best way to say it. What I meant to say is global x axis LABEL and >> y-axis LABEL. This can be seen in this example ( >> http://www.scipy.org/Cookbook/Matplotlib/Multiple_Subplots_with_One_Axis_Label?action=AttachFile&do=get&target=Same_ylabel_subplots.png >> ) >> >> although when I tried to do something similar with a 2x2 grid of plots it >> didn't seem to be working for me. Their example works due to these lines >> here >> >> import pylab >>> 2 >>> 3 figprops = dict(figsize=(8., 8. / 1.618), dpi=128) >>> # Figure properties >>> 4 adjustprops = dict(left=0.1, bottom=0.1, right=0.97, top=0.93, >>> wspace=0.2 hspace=0.2) # Subplot properties >>> 5 >>> 6 fig = pylab.figure(**figprops) >>> # New figure >>> 7 fig.subplots_adjust(**adjustprops) >>> # Tunes the subplot layout >>> 8 >>> 9 ax = fig.add_subplot(3, 1, 1) >>> 10 bx = fig.add_subplot(3, 1, 2, sharex=ax, sharey=ax) >>> 11 cx = fig.add_subplot(3, 1, 3, sharex=ax, sharey=ax) >>> 12 >>> 13 ax.plot([0,1,2], [2,3,4], 'k-') >>> 14 bx.plot([0,1,2], [2,3,4], 'k-') >>> 15 cx.plot([0,1,2], [2,3,4], 'k-') >>> 16 >>> 17 pylab.setp(ax.get_xticklabels(), visible=False) >>> 18 pylab.setp(bx.get_xticklabels(), visible=False) >>> 19 >>> 20 bx.set_ylabel('This is a long label shared among more axes', >>> fontsize=14) >>> 21 cx.set_xlabel('And a shared x label', fontsize=14) >> >> >> >> specifically probably the bx/cx_set label commands coupled with the sharex >> commands in the subplot label. But when I tried to add these things for my >> 2x2 plot it always looked like the label was attached to one of the plots or >> another instead of spanning the whole range. >> >> Thanks, >> Brad >> >> > Maybe the label_outer() function will be what you need. Call it for each > subplot axes, and set the labels as you would normally. matplotlib would > then set visible only the labels that are on the outside edge. > > Another option is to use the AxesGrid1 toolkit, which makes these things > easy. Also note that the soon-to-be released v1.1 will have a > tight_layout() function that can help with your spacing issues. > > Cheers! > Ben Root > > |