tick labeling question

Hi all

How can I change the default behavior of the tick labeling from say

1 2 3 4 x1e-5

to

1e-5 2e-5 3e-5 4e-5 ?

My thesis supervisor wants it that way :frowning:

cheers,
steve

···

--
Random number generation is the art of producing pure gibberish as quickly as possible.

There is problably a better way, but onne way is to set the label formatter yourself:

import pylab
import matplotlib

pylab.plot([1.0E-5,2.5E-5,3.0E-5], [1.0, 3.0, 2.0])

ax = pylab.gca()
ax.xaxis.set_major_formatter(
matplotlib.ticker.FormatStrForm
atter(’%g’))

pylab.show()

You can craft an arbitrarily constructed string by using matplotlib.ticker.FuncFormatter

instead of matplotlib.ticker.FormatStrFormatter.

Hope this helps,
Alex

···

On 8/3/06, Steve Schmerler <elcorto@…361…> wrote:

Hi all

How can I change the default behavior of the tick labeling from say

1 2 3 4 x1e-5

to

1e-5 2e-5 3e-5 4e-5 ?

My thesis supervisor wants it that way :frowning:

cheers,
steve

Use OldScalarFormatter instead.

···

On Thursday 03 August 2006 11:59, Alexander Michael wrote:

On 8/3/06, Steve Schmerler <elcorto@...361...> wrote:
> Hi all
>
> How can I change the default behavior of the tick labeling from say
>
> 1 2 3 4 x1e-5
>
> to
>
> 1e-5 2e-5 3e-5 4e-5 ?
>
> My thesis supervisor wants it that way :frowning:
>
> cheers,
> steve

There is problably a better way, but onne way is to set the label
formatter yourself:

import pylab
import matplotlib

pylab.plot([1.0E-5,2.5E-5,3.0E-5], [1.0, 3.0, 2.0])

ax = pylab.gca()
ax.xaxis.set_major_formatter(
    matplotlib.ticker.FormatStrFormatter('%g'))

Darren Dale wrote:

···

On Thursday 03 August 2006 11:59, Alexander Michael wrote:

On 8/3/06, Steve Schmerler <elcorto@...361...> wrote:

Hi all

How can I change the default behavior of the tick labeling from say

1 2 3 4 x1e-5

to

1e-5 2e-5 3e-5 4e-5 ?

My thesis supervisor wants it that way :frowning:

cheers,
steve

There is problably a better way, but onne way is to set the label
formatter yourself:

import pylab
import matplotlib

pylab.plot([1.0E-5,2.5E-5,3.0E-5], [1.0, 3.0, 2.0])

ax = pylab.gca()
ax.xaxis.set_major_formatter(
    matplotlib.ticker.FormatStrFormatter('%g'))

Use OldScalarFormatter instead.

OK, I'll try that one too ...

Thanks.

--
Random number generation is the art of producing pure gibberish as
quickly as possible.

Alexander Michael wrote:

tick_test.py (1.38 KB)

···

On 8/3/06, *Steve Schmerler* <elcorto@…361… <mailto:elcorto@…361…>> > wrote:

    Hi all

    How can I change the default behavior of the tick labeling from say

    1 2 3 4 x1e-5

    to

    1e-5 2e-5 3e-5 4e-5 ?

    My thesis supervisor wants it that way :frowning:

    cheers,
    steve

There is problably a better way, but onne way is to set the label formatter yourself:

import pylab
import matplotlib

pylab.plot([1.0E-5,2.5E-5,3.0E-5], [1.0, 3.0, 2.0])

ax = pylab.gca()
ax.xaxis.set_major_formatter(
    matplotlib.ticker.FormatStrForm
atter('%g'))

pylab.show()

You can craft an arbitrarily constructed string by using matplotlib.ticker.FuncFormatter
instead of matplotlib.ticker.FormatStrFormatter.

Hope this helps,
Alex

Yes, after a look at the docs I found that FuncFormatter is what I
wanted. With the help of a little function (which I wrote some time ago)
that converts a float number into a raw string I can use FuncFormatter
straightforward (see attached file).

cheers,
steve

--
Random number generation is the art of producing pure gibberish as
quickly as possible.