x and y labels that span multiple axes

Hi all,

I'm plotting a set of subplots (2 x 3) and I'd like to label the x and y
axes with one title each (i.e. spanning the axes) since the units of all
the x axes and y axes are the same. I know that I can use fig.text to
do it, though that would require some fiddling on my part to get the
placement right. Is there an easier way?

Jon

···

--
______________________________________________________________
Jonathan D. Slavin Harvard-Smithsonian CfA
jslavin@...1081... 60 Garden Street, MS 83
phone: (617) 496-7981 Cambridge, MA 02138-1516
cell: (781) 363-0035 USA
______________________________________________________________

Hi Jon,

The way I do this is to create a "master" axis that overlaps the others with dimensions equal to the outer border of all the other axes. Then I just use this axis for the labels:
masterAxis.set_xlabel("ick")
masterAxis.set_ylabel("blech")

You also have to turn off ticks and tick labels for this axis:
masterAxis.xaxis.set_major_formatter(mpl.ticker.NullFormatter())
masterAxis.yaxis.set_major_formatter(mpl.ticker.NullFormatter())

Since it doesn't know about tick labels, it may not position the axis labels far enough away from the axis line, so you can adjust the spacing:
masterAxis.xaxis.labelpad += 6
masterAxis.yaxis.labelpad += 4

It's still a little fiddly, but less fiddly than using fig.text. I bet this could be significantly improved, e.g. with Axes_Grid, but I don't know how to do that.

Cheers,
Jeff

···

On Mar 9, 2012, at 1:05 PM, Jonathan Slavin wrote:

Hi all,

I'm plotting a set of subplots (2 x 3) and I'd like to label the x and y
axes with one title each (i.e. spanning the axes) since the units of all
the x axes and y axes are the same. I know that I can use fig.text to
do it, though that would require some fiddling on my part to get the
placement right. Is there an easier way?

Jon