semilogx font problem

Hmm, the following is certainly closer than my fool-headed attempt at \rm

        usetex = rcParams['text.usetex']
        if not isDecade and self.labelOnlyBase: s = ''
        elif not isDecade:
            if usetex: s = r'\\textnormal\{%d\}^\\textnormal\{%\.2f\}'% (b, fx)
            else: s = '%d^\{%\.2f\}'% (b, fx)
        else:
            if usetex: s = r'\\textnormal\{%d\}^\\textnormal\{%d\}'% (b, self.nearest_long(fx))
            else: s = r'%d^\{%d\}'% (b, self.nearest_long(fx))

but the '1's still look different on my system.

Is there any reason you applied the textnormal only to the exponent
and not the base (other than running out the door)?

JDH

···

On Wednesday 12 April 2006 17:13, Ryan Krauss wrote:

    >> I am having a font problem with semilogx, usetex=true and
    >> font.family:sans-serif. The xticks are using a serif font.
    >> These lines are enough to recreate the problem on my machine.
    >>
    >> t=arange(0,1,0.01) y=sin(2*pi*t) figure(10) semilogx(t,y)
    >> ylabel('Mag.') xlabel('Time (sec.)') savefig('test.png')

    > You might be able to do something like this in
    > LogFormatterMathtext:

    > if rcParams['text.usetex']: if not isDecade and
    > self.labelOnlyBase: s = '' elif not isDecade: s =
    > '%d$^\textnormal{%.2f}'% \(b, fx\) else: s =     > '%d^\\textnormal\{%d\}'% (b, self.nearest_long(fx))

    > I dont have time to test it, I'm running out the door.

My quick attempt only enters math mode to typeset the exponent. Its a useful
trick for dealing with stoichiometry: SrTiO$_3$

···

On Wednesday 12 April 2006 6:13 pm, John Hunter wrote:

    > On Wednesday 12 April 2006 17:13, Ryan Krauss wrote:
    >> I am having a font problem with semilogx, usetex=true and
    >> font.family:sans-serif. The xticks are using a serif font.
    >> These lines are enough to recreate the problem on my machine.
    >>
    >> t=arange(0,1,0.01) y=sin(2*pi*t) figure(10) semilogx(t,y)
    >> ylabel('Mag.') xlabel('Time (sec.)') savefig('test.png')

    > You might be able to do something like this in
    > LogFormatterMathtext:

    > if rcParams['text.usetex']: if not isDecade and
    > self.labelOnlyBase: s = '' elif not isDecade: s =
    > '%d$^\textnormal{%.2f}'% \(b, fx\) else: s =     > '%d^\\textnormal\{%d\}'% (b, self.nearest_long(fx))

    > I dont have time to test it, I'm running out the door.

Hmm, the following is certainly closer than my fool-headed attempt at \rm

        usetex = rcParams['text.usetex']
        if not isDecade and self.labelOnlyBase: s = ''
        elif not isDecade:
            if usetex: s = r'\\textnormal\{%d\}^\\textnormal\{%\.2f\}'% (b, fx)
            else: s = '%d^\{%\.2f\}'% (b, fx)
        else:
            if usetex: s = r'\\textnormal\{%d\}^\\textnormal\{%d\}'% (b,
self.nearest_long(fx)) else: s = r'%d^\{%d\}'% (b,
self.nearest_long(fx))

but the '1's still look different on my system.

Is there any reason you applied the textnormal only to the exponent
and not the base (other than running out the door)?

I think I came up with a workable solution, which I committed in svn 2292. I
also fixed the formatting of the scientific notation label to make it work
with usetex and sans-serif fonts. The scalarformatter code was my first
contribution to the mpl codebase, and man is it ugly. I have a hard time
following the logic anymore. I'll probably refactor it one of these days.

Also, I noticed that the offset functionality isn't working anymore. I think
it is due to the call to self.viewInterval.span(), the following plot exposes
the problem:

plot([1,2], array([1, 2])*1e-12+1e-5)

That used to give a plot with properly scaled yaxis, such that the ticks were
labeled [1,...,2] and the offset text said 'x10^-12 + 1e-5'. Any ideas on
what has changed?

Darren

···

On Wednesday 12 April 2006 18:13, John Hunter wrote:

    > On Wednesday 12 April 2006 17:13, Ryan Krauss wrote:
    >> I am having a font problem with semilogx, usetex=true and
    >> font.family:sans-serif. The xticks are using a serif font.
    >> These lines are enough to recreate the problem on my machine.
    >>
    >> t=arange(0,1,0.01) y=sin(2*pi*t) figure(10) semilogx(t,y)
    >> ylabel('Mag.') xlabel('Time (sec.)') savefig('test.png')

    > You might be able to do something like this in
    > LogFormatterMathtext:

    > if rcParams['text.usetex']: if not isDecade and
    > self.labelOnlyBase: s = '' elif not isDecade: s =
    > '%d$^\textnormal{%.2f}'% \(b, fx\) else: s =     > '%d^\\textnormal\{%d\}'% (b, self.nearest_long(fx))

    > I dont have time to test it, I'm running out the door.

Hmm, the following is certainly closer than my fool-headed attempt at \rm

        usetex = rcParams['text.usetex']
        if not isDecade and self.labelOnlyBase: s = ''
        elif not isDecade:
            if usetex: s = r'\\textnormal\{%d\}^\\textnormal\{%\.2f\}'% (b, fx)
            else: s = '%d^\{%\.2f\}'% (b, fx)
        else:
            if usetex: s = r'\\textnormal\{%d\}^\\textnormal\{%d\}'% (b,
self.nearest_long(fx)) else: s = r'%d^\{%d\}'% (b,
self.nearest_long(fx))

but the '1's still look different on my system.