## Re: [PyX-user] Base for logarithmic axis

 Re: [PyX-user] Base for logarithmic axis From: James McDermott - 2007-03-12 14:03:31 ```On 3/12/07, I wrote: > Hi all, > > I wonder if there is a way to change the base used to calculate the > logarithmic mapping for graph.axis.logarithmic? [...] By the way, I've looked at examples/axis/log.py, and I don't think that's the solution - it allows changing the rater and parter and so on, but (to quote the manual) it is graph.axis.axis which "Implements the conversion of a data value to a graph coordinate of range [0:1]." I understand the parter to be responsible only for choosing the tick placements. James ```

 [PyX-user] Base for logarithmic axis From: James McDermott - 2007-03-12 10:41:56 ```Hi all, I wonder if there is a way to change the base used to calculate the logarithmic mapping for graph.axis.logarithmic? I have some random points generated uniformly on [0, 1] and then mapped using an exponential function (which I'll paste in at the end -- there is a factor of k which might seem strange but this mapping is used by a trusted example in my problem domain!) When I graph these points in PyX, they don't appear uniform on the X-axis: if it's a linear axis, they are bunched on the left; if it's a logarithmic axis, they are bunched on the right. I think if I could set the base for the log axis to k, I could get the right result? James -- James McDermott PhD candidate in Music Technology CSG026, Dept. Computer Science and Information Systems, University of Limerick, Ireland. http://www.skynet.ie/~jmmcd -- Here's an example program which demonstrates my problem: -- #!/usr/bin/env python from pyx import * import random import math # map x from [0, 1] to [minv, maxv] def exp_map(minv, maxv, x): k = 5.0 return minv + (maxv - minv) * ((math.exp(k * x) - 1) / (math.exp(k) - 1)) r = [(exp_map(0.0, 10.0, random.random()), random.random()) for i in range(100)] xaxes = [("lin", graph.axis.lin()), ("log", graph.axis.log())] for name, xaxis in xaxes: g = graph.graphxy(width=6, x=xaxis) g.plot(graph.data.list(r, x=1, y=2)) g.writeEPSfile(name) ```
 Re: [PyX-user] Base for logarithmic axis From: James McDermott - 2007-03-12 14:03:31 ```On 3/12/07, I wrote: > Hi all, > > I wonder if there is a way to change the base used to calculate the > logarithmic mapping for graph.axis.logarithmic? [...] By the way, I've looked at examples/axis/log.py, and I don't think that's the solution - it allows changing the rater and parter and so on, but (to quote the manual) it is graph.axis.axis which "Implements the conversion of a data value to a graph coordinate of range [0:1]." I understand the parter to be responsible only for choosing the tick placements. James ```
 Re: [PyX-user] Base for logarithmic axis From: James McDermott - 2007-03-12 17:16:16 ```Hi again, [replying to himself as if it were going out of fashion... when it's already deeply unfashionable] On 3/12/07, I wrote: > > I wonder if there is a way to change the base used to calculate the > > logarithmic mapping for graph.axis.logarithmic? > > By the way, I've looked at examples/axis/log.py, and I don't think > that's the solution It was pointed out to me off-list that my mapping isn't going to yield a distribution with logarithmic probability density, therefore my attempts to use the custom parter solution in examples/axis/log.py weren't going to work anyway. Using a more natural mapping function does indeed give nice uniform-looking distributions when graphed using graph.axis.log. Sorry for the noise, James -- For the record: # map x from [0, 1] to [minv, maxv] def exp_map2(minv, maxv, x): return math.exp(math.log(minv) + x * (math.log(maxv) - math.log(minv))) ```