tickmark font and placement question

My love of large fonts is causing a problem. If you look at

    > the attached figure, I typically have x and y tick marks
    > that nearly collide in the lower left hand corner of each
    > subplot. I typically end up setting the yticks by hand, but
    > this isn't super convienent for each plot. I am about to
    > right a function to drop the lowest ytick label, but is
    > there a better approach?

Increase the xtick.major.pad and/or ytick.major.pad rc settings by a
couple of points.

Alternatively, if you do want to drop the leftmost xtick label, for
instance, you can easily derive a custom formatter. Here you are using
the LogFormatterMathtext

from matplotlib.ticker import LogFormatterMathtext

class MyFormatter(LogFormatterMathtext):
    def __call__(self, x, pos=None):
        if pos==0: return '' # pos=0 is the first tick
        else: return LogFormatterMathtext(self, x, pos)

ax.xaxis.set_major_formatter(MyFormatter())

Nice looking figure!
JDH

The new formatter works pretty well. One change though, the last line
should be:

else: return LogFormatterMathtext.__call__(self, x, pos)

Thanks,

John

···

On 4/13/06, John Hunter <jdhunter@...4...> wrote:

    > My love of large fonts is causing a problem. If you look at
    > the attached figure, I typically have x and y tick marks
    > that nearly collide in the lower left hand corner of each
    > subplot. I typically end up setting the yticks by hand, but
    > this isn't super convienent for each plot. I am about to
    > right a function to drop the lowest ytick label, but is
    > there a better approach?

Increase the xtick.major.pad and/or ytick.major.pad rc settings by a
couple of points.

Alternatively, if you do want to drop the leftmost xtick label, for
instance, you can easily derive a custom formatter. Here you are using
the LogFormatterMathtext

from matplotlib.ticker import LogFormatterMathtext

class MyFormatter(LogFormatterMathtext):
    def __call__(self, x, pos=None):
        if pos==0: return '' # pos=0 is the first tick
        else: return LogFormatterMathtext(self, x, pos)

ax.xaxis.set_major_formatter(MyFormatter())

Nice looking figure!
JDH

Hi,

I have a related question. How do I change the (font)size of the ticklabels,
without having to step through them?
I have "ganged" plots and am scaling fonts by a factor depending on nrows and
ncolumns.
I also need this for the size of the legend "labels"

Cheers,
Malte

···

On Friday 14 April 2006 04:25, Ryan Krauss wrote:

The new formatter works pretty well. One change though, the last line
should be:

else: return LogFormatterMathtext.__call__(self, x, pos)

Thanks,

John

On 4/13/06, John Hunter <jdhunter@...4...> wrote:

>
> > My love of large fonts is causing a problem. If you look at
> > the attached figure, I typically have x and y tick marks
> > that nearly collide in the lower left hand corner of each
> > subplot. I typically end up setting the yticks by hand, but
> > this isn't super convienent for each plot. I am about to
> > right a function to drop the lowest ytick label, but is
> > there a better approach?
>
> Increase the xtick.major.pad and/or ytick.major.pad rc settings by a
> couple of points.
>
> Alternatively, if you do want to drop the leftmost xtick label, for
> instance, you can easily derive a custom formatter. Here you are using
> the LogFormatterMathtext
>
> from matplotlib.ticker import LogFormatterMathtext
>
> class MyFormatter(LogFormatterMathtext):
> def __call__(self, x, pos=None):
> if pos==0: return '' # pos=0 is the first tick
> else: return LogFormatterMathtext(self, x, pos)
>
> ax.xaxis.set_major_formatter(MyFormatter())
>
> Nice looking figure!
> JDH