Minor tick labels

Hi all,

I am trying to change the labels of minor ticks, but leave the labels of the major ticks unchanged. To do this, I use the following function:

ax = plt.subplot(111)
ax.set_xticks([1,3,5])
ax.set_xticks([2,4], minor=True)
ax.set_xticklabels(["a", "b"], minor=True)

However, in result of the function both minor and major tick labels are changes. I checked the source code of XAxis.set_ticklabels and it contains following lines:

axis.py: lines 1335-1342

        if minor:
            self.set_minor_formatter(mticker.FixedFormatter(ticklabels))
            ticks = self.get_minor_ticks()
        else:
            self.set_major_formatter( mticker.FixedFormatter(ticklabels) )
            ticks = self.get_major_ticks()

        self.set_major_formatter( mticker.FixedFormatter(ticklabels) )

Note that the last lines sets the major tick formatter regardless of the "minor" argument. Is it intentional behaviour?

Yours,

Bartosz

Thanks for the report (and the good detective work). Fixed in trunk.

(As far as I can tell, this is due to an SVN merge error from the
transforms branch.)

Ryan

···

On Tue, Jun 29, 2010 at 7:16 AM, Bartosz Telenczuk <b.telenczuk@...2786...> wrote:

Hi all,

I am trying to change the labels of minor ticks, but leave the labels of the major ticks unchanged. To do this, I use the following function:

ax = plt.subplot(111)
ax.set_xticks([1,3,5])
ax.set_xticks([2,4], minor=True)
ax.set_xticklabels(["a", "b"], minor=True)

However, in result of the function both minor and major tick labels are changes. I checked the source code of XAxis.set_ticklabels and it contains following lines:

axis.py: lines 1335-1342

   if minor:
       self\.set\_minor\_formatter\(mticker\.FixedFormatter\(ticklabels\)\)
       ticks = self\.get\_minor\_ticks\(\)
   else:
       self\.set\_major\_formatter\( mticker\.FixedFormatter\(ticklabels\) \)
       ticks = self\.get\_major\_ticks\(\)

   self\.set\_major\_formatter\( mticker\.FixedFormatter\(ticklabels\) \)

Note that the last lines sets the major tick formatter regardless of the "minor" argument. Is it intentional behaviour?

--
Ryan May
Graduate Research Assistant
School of Meteorology
University of Oklahoma