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.