Log axes and setting ticks: not working

When I run the following script:

import numpy as N
from pylab import *
t = N.arange[0,8*N.pi, 0.1]
y = N.sin(t)

figure()
plot(t,y)
xticks(N.arange(0,8*N.pi, N.pi))

figure()
semilogx(t,y)
xticks(N.arange(0,8*N.pi, N.pi))

The first plot will work fine, and set the x-ticks to be multiples of
pi, as desired.

However, the second plot does not work. I have verified this is the
case whenever log axes are used: you can't then set the x-ticks or
labels.

Is this a bug or a design feature? I am interested in doing this since
I am plotting FFTs on a log-log plot, and wish to label the x-axis
('100 kHz', '1 MHz', etc...) and the y-axis in dB.

If it helps, there are two errors that are given. The first is when
attempting calling the xticks function, which throws an exception:

C:\Python24\lib\site-packages\matplotlib\figure.py in draw(self, renderer)
    527
    528 # render the axes
--> 529 for a in self.axes: a.draw(renderer)
    530
    531 # render the figure text

C:\Python24\lib\site-packages\matplotlib\axes.py in draw(self, renderer, infram
)
   1407 renderer.open_group('axes')
   1408
-> 1409 try: self.transData.freeze() # eval the lazy objects
   1410 except ValueError:
   1411 print >> sys.stderr, 'data freeze value error', self.get_po
ition(), self.dataLim.get_bounds(), self.viewLim.get_bounds()

ValueError: Domain error on eval_scalars in Transformation::freeze

The second is then when the mouse is moved over the plot, or we try to
update the plot, and the exceptions are:

  File "C:\Python24\lib\site-packages\matplotlib\axes.py", line 633,
in format_coord
    xs = self.format_xdata(x)
  File "C:\Python24\lib\site-packages\matplotlib\axes.py", line 615,
in format_xdata
    val = func(x)
  File "C:\Python24\lib\site-packages\matplotlib\ticker.py", line 401,
in format_data
    value = strip_math(self.__call__(value))
  File "C:\Python24\lib\site-packages\matplotlib\ticker.py", line 471,
in __call__
    fx = math.log(x)/math.log(b)
TypeError: a float is required

Thanks,
Josh

It is neither. log(0) is not plottable, you need to pick more appropriate
xticks.

···

On Monday 03 April 2006 10:57 pm, Josh Marshall wrote:

When I run the following script:

import numpy as N
from pylab import *
t = N.arange[0,8*N.pi, 0.1]
y = N.sin(t)

figure()
plot(t,y)
xticks(N.arange(0,8*N.pi, N.pi))

figure()
semilogx(t,y)
xticks(N.arange(0,8*N.pi, N.pi))

The first plot will work fine, and set the x-ticks to be multiples of
pi, as desired.

However, the second plot does not work. I have verified this is the
case whenever log axes are used: you can't then set the x-ticks or
labels.

Is this a bug or a design feature?