Thread view

Hi All,
I can't get the x label on the top row of an ImageGrid to display if there
is more than one row in the grid. I suspect that something is being clipped
somewhere, but have no idea what to do to fix it. (Note, this also happens
on the right edge of a ride-sided y axis label.)
I have included some minimal sample code below. I'd appreciate it if anyone
can point me in the right direction.
Cheers,
Russ
#-------------------------------
import matplotlib.pyplot as plt
import matplotlib.cm as cm
import mpl_toolkits.axes_grid1 as ag
import numpy as np
fig1 = plt.figure()
grid1 = ag.AxesGrid( fig1, 111, nrows_ncols = (1,2), axes_pad = 0.5)
grid1[0].axes.xaxis.set_label_position('top')
grid1[0].axes.xaxis.set_label_text('foo')
grid1[1].axes.xaxis.set_label_position('top')
grid1[1].axes.xaxis.set_label_text('bar')
grid1[0].axes.yaxis.set_label_position('right')
grid1[0].axes.yaxis.set_label_text('foo')
grid1[1].axes.yaxis.set_label_position('right')
grid1[1].axes.yaxis.set_label_text('bar')
fig2 = plt.figure()
grid2 = ag.AxesGrid( fig2, 111, nrows_ncols = (2,1), axes_pad = 0.5)
grid2[0].axes.xaxis.set_label_position('top')
grid2[0].axes.xaxis.set_label_text('bar')
grid2[1].axes.xaxis.set_label_position('top')
grid2[1].axes.xaxis.set_label_text('bar')
grid2[0].axes.yaxis.set_label_position('right')
grid2[0].axes.yaxis.set_label_text('foo')
grid2[1].axes.yaxis.set_label_position('right')
grid2[1].axes.yaxis.set_label_text('bar')
plt.show()
#-------------------------------
--
Russell J. Hewett
Ph.D. Candidate
Department of Computer Science
University of Illinois at Urbana-Champaign
http://www.russellhewett.com

Russell Hewett, on 2011-01-24 13:56, wrote:
> Hi All,
>
> I can't get the x label on the top row of an ImageGrid to display if there
> is more than one row in the grid. I suspect that something is being clipped
> somewhere, but have no idea what to do to fix it. (Note, this also happens
> on the right edge of a ride-sided y axis label.)
>
> I have included some minimal sample code below. I'd appreciate it if anyone
> can point me in the right direction.
>
>
> Cheers,
> Russ
Hi Russ,
thanks for the report - at a glance, it appears to be a bug in
AxesGrid removing redundant labels for shared axis when they
align. I've included a temporary workaround for your script, but
don't have time to look into it further at the moment. By the
way, calling grid[0].axes is redundant, so I just modified it to
use grid[0].xaxis, which is equivalent.
#-------------------------------
import matplotlib.pyplot as plt
import matplotlib.cm as cm
import mpl_toolkits.axes_grid1 as ag
import numpy as np
fig1 = plt.figure()
grid1 = ag.AxesGrid( fig1, 111, nrows_ncols = (1,2), axes_pad = 0.5)
grid1[0].xaxis.set_label_position('top')
grid1[0].xaxis.set_label_text('foo')
grid1[1].xaxis.set_label_position('top')
grid1[1].xaxis.set_label_text('bar')
grid1[0].yaxis.set_label_position('right')
grid1[0].yaxis.set_label_text('foo')
grid1[1].yaxis.set_label_position('right')
grid1[1].yaxis.set_label_text('bar')
grid1[1].yaxis.label.set_visible(True) # tmp workaround
fig2 = plt.figure()
grid2 = ag.AxesGrid( fig2, 111, nrows_ncols = (2,1), axes_pad = 0.5)
grid2[0].xaxis.set_label_position('top')
grid2[0].xaxis.set_label_text('bar')
grid2[0].xaxis.label.set_visible(True) # tmp workaround
grid2[1].xaxis.set_label_position('top')
grid2[1].xaxis.set_label_text('bar')
grid2[0].yaxis.set_label_position('right')
grid2[0].yaxis.set_label_text('foo')
grid2[1].yaxis.set_label_position('right')
grid2[1].yaxis.set_label_text('bar')
plt.show()
#-------------------------------
best,
--
Paul Ivanov
314 address only used for lists, off-list direct email at:
http://pirsquared.org | GPG/PGP key id: 0x0F3E28F7

This is indeed correct. Somehow I missed this. Setting label_mode = 'all'
gets the behavior I wanted.
Though, the top and right side are technically on the outside too. Perhaps
that should be an available or the default setting? Perhaps the top row
should default to labeling on the top, the right column default to labeling
on the right, etc?
-r
On Mon, Jan 24, 2011 at 5:56 PM, Benjamin Root <ben.root@...> wrote:
>
>
> Isn't it a feature? Axes_grid lets you choose the label mode which is
> 'L' by default. This means that only the outer labels are shown. Or
> am I missing something in the description of the problem?
>
> Ben Root
>
--
Russell J. Hewett
Ph.D. Candidate
Department of Computer Science
University of Illinois at Urbana-Champaign
http://www.russellhewett.com

On Tue, Jan 25, 2011 at 10:43 AM, Russell Hewett <rhewett2@...> wrote:
> Though, the top and right side are technically on the outside too. Perhaps
> that should be an available or the default setting? Perhaps the top row
> should default to labeling on the top, the right column default to labeling
> on the right, etc?
>
As the mode name "L" implies, it means "left" and "bottom" side (of
the whole grid).
Maybe we can have an "outer" mode. Any contribution will be welcomed.
Regards,
-JJ