Bug in xscale? Or wrong way to plot log x-axis scale with negative values?

Hi all,

I’m plotting data which extent, in x, from -1000 to 1000. But I’m only interested in the values between x = -1 and 0.

I also want to plot on an x log scale. But since the x-values are negative, I cannot use xscale(“log”). I can use xscale(“symlog”) though and this is the behaviour I want.

Unfortunately, “symlog” seems to be broken. I cannot use the linthreshx argument with a value of less then 2 (the default?). But since I’m interested in x values from -1 to 0, I have to use that argument and set it to something like 1e-5 or even smaller.

If I set linthreshx to something smaller then 1, the plot breaks. Here is a simple example, taken from http://stackoverflow.com/questions/3305865/what-is-the-difference-between-log-and-symlog

import numpy
from matplotlib import pyplot

Enable interactive mode

pyplot.ion()

Draw the grid lines

pyplot.grid(True)

Numbers from -50 to 50, with 0.1 as step

xdomain = numpy.arange(-50,50, 0.1)

Plots a simple linear function ‘f(x) = x’

pyplot.plot(xdomain, xdomain)

Plots ‘sin(x)’

pyplot.plot(xdomain, numpy.sin(xdomain))

pyplot.xscale(‘symlog’, linthreshx=0.1)

The problem seems to be that, on the x-axis, 0 is actually 10^0 = 1, not 0. Putting something smaller then 1 will make the line go back and the axis values are wrong (when hovering with the mouse and getting the x value).

I might not be using the right tool though, but how to achieve what I want? I want the x axis to look like:
-10^2 -10^1 -10^0 -10^-1 -10^-2 -10^-3 … [up to my defined minimum exponent] … 10^-3 10^-2 10^-1 10^0 10^1 10^2

Thank you

Nicolas