Xtick label size in ImageGrid

I just refactored some custom code to make use of
axes_grid1.ImageGrid, and I think I've come across a bug (see below).
It looks like the tick labelsize doesn't get passed properly to the
parasite axes.

I'm using Python2.6, matplotlib-1.0.0 release, and the Qt4Agg backend.

Also, I noticed that the Grid.__init__ super-class constructor isn't
called in the ImageGrid.__init__ constructor; should it be?

By way of feature request, I'd prefer to be able to specify share_x
and share_y in the constructor, but that's not available in ImageGrid,
only in Grid.

If there's agreement that this is bug, I'll file it on the sourceforge
tracker. Is this fixed in SVN, or does anyone have workaround, e.g.,
some way to convert 'x-small' to the correct integer size, or a
different method to call?

Thanks,
    Justin

···

========
from mpl_toolkits.axes_grid1 import ImageGrid
import pylab
import numpy
row_height = 10
fi = pylab.figure()
grid = ImageGrid(fi, 111, nrows_ncols=(5,1), share_all=False, label_mode='l')
for i in range(5):
    a = abs(numpy.random.randn(5,100))
    im = grid[i].imshow(a)

cb = grid.cbar_axes[0].colorbar(im)
for ax in grid.axes_all:
    ax.set_yticks([])

# oops - this only changes the lowest Axes formatting
grid.axes_llc.tick_params(direction='out', labelsize='x-small')
pylab.show()
# Now pan to the left a bit-- you'll see the large 0 from the 100 xtick_label

# Let's try explicitly setting all of the xtick sizes. Kablooie.
for ax in grid.axes_all:
ax.tick_params(direction='out', labelsize='x-small')

---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
/tmp/<ipython console> in <module>()
.../matplotlib/axes.pyc in tick_params(self, axis, **kwargs)
2215 xkw.pop('labelleft', None)
2216 xkw.pop('labelright', None)
-> 2217 self.xaxis.set_tick_params(**xkw)
2218 if axis in ['y', 'both']:
2219 ykw = dict(kwargs)
.../matplotlib/axis.pyc in set_tick_params(self, which, reset, **kw)
795 if which == 'major' or which == 'both':
796 for tick in self.majorTicks:
--> 797 tick._apply_params(**self._major_tick_kw)
798 if which == 'minor' or which == 'both':
799 for tick in self.minorTicks:
.../matplotlib/axis.pyc in _apply_params(self, **kw)
274 if dirpad:
275 self._base_pad = kw.pop('pad', self._base_pad)
--> 276 self.apply_tickdir(kw.pop('tickdir', self._tickdir))
277 trans = self._get_text1_transform()[0]
278 self.label1.set_transform(trans)
.../matplotlib/axis.pyc in apply_tickdir(self, tickdir)
331 else:
332 self._tickmarkers = (mlines.TICKDOWN, mlines.TICKUP)
--> 333 self._pad = self._base_pad + self._size
334
335
TypeError: unsupported operand type(s) for +: 'int' and 'str'

The label_mode need to be capital "L", instead of "l". I guess this
will fix your first problem.
While we make "l" same as "L", but I think it actually degrade the
readability of the code, and I;m inclined to leave it as is. Let me
know if you have any suggestions though.

# Let's try explicitly setting all of the xtick sizes. Kablooie.
for ax in grid.axes_all:
ax.tick_params(direction='out', labelsize='x-small')

The second one is not actually related with axes_grid1 toolkit. The
error can be reproduced with the code below.

ax = subplot(111)
ax.tick_params(direction='out', labelsize='x-small')
ax.tick_params(direction='out', labelsize='x-small')

The 1st tick_params is okay, but the 2nd one raises an error.
I'll take a look into it soon. Meanwhile, you may use a numeric
argument for the labelsize.

Regards,

-JJ

···

On Sat, Oct 9, 2010 at 5:43 AM, Justin McCann <jneilm@...287...> wrote:

Eric,

ax = subplot(111)
ax.tick_params(labelsize='x-small')
print ax.xaxis.majorTicks[0]._size

it sets Tick._size instead of Tick._labelsize, which seems to be a bug.

I think the below patch fixes this. Can you check (and commit if correct)?

Regards,

-JJ

diff --git a/lib/matplotlib/axis.py b/lib/matplotlib/axis.py
index 585c1a2..05e7bec 100644
--- a/lib/matplotlib/axis.py
+++ b/lib/matplotlib/axis.py
@@ -299,7 +299,7 @@ class Tick(artist.Artist):
             label_kw = dict([(k[5:], v) for (k, v) in label_list])
             self.label1.set(**label_kw)
             self.label2.set(**label_kw)
- for k, v in label_kw.items():
+ for k, v in label_list:
                 setattr(self, '_'+k, v)

···

On Sat, Oct 9, 2010 at 12:10 PM, Jae-Joon Lee <lee.j.joon@...287...> wrote:

The label_mode need to be capital "L", instead of "l". I guess this
will fix your first problem.
While we make "l" same as "L", but I think it actually degrade the
readability of the code, and I;m inclined to leave it as is. Let me
know if you have any suggestions though.

On Sat, Oct 9, 2010 at 5:43 AM, Justin McCann <jneilm@...287...> wrote:

# Let's try explicitly setting all of the xtick sizes. Kablooie.
for ax in grid.axes_all:
ax.tick_params(direction='out', labelsize='x-small')

The second one is not actually related with axes_grid1 toolkit. The
error can be reproduced with the code below.

ax = subplot(111)
ax.tick_params(direction='out', labelsize='x-small')
ax.tick_params(direction='out', labelsize='x-small')

The 1st tick_params is okay, but the 2nd one raises an error.
I'll take a look into it soon. Meanwhile, you may use a numeric
argument for the labelsize.

Regards,

-JJ

Sorry for the delayed response, but I've been trying to think of a
decent suggestion.

The capital "L" fixed the problem with the extra xticks. I had
completely misread it; I was trying to label the lower-left axes only
with a lower-case "L" ("l") and really needed a one ("1").

How about "bottom" instead of "L", and "lower left" instead of "1"?
You might consider using the "bottom", "lower left", "top", ...
pattern if you want to support other locations.

     Justin

···

On Fri, Oct 8, 2010 at 11:10 PM, Jae-Joon Lee <lee.j.joon@...287...> wrote:

The label_mode need to be capital "L", instead of "l". I guess this
will fix your first problem.
While we make "l" same as "L", but I think it actually degrade the
readability of the code, and I;m inclined to leave it as is. Let me
know if you have any suggestions though.