# how to get a log distribution on the x-axis of a semilogx plot?

I tried to plot some frequency response. In the most simple case this may look like A(w). I can make plots using different statements like plot_semiogx, or plot(...,scale='semilogx') etc, but the results look odd. Apparently the internally generated points on the x-axis lways have a linear distribution. Only forcing an exaggerated number of points (e.g. plot_points=100000) results in a correct graph. I didn't find a better solution. I think the plot command should distribute the x-points in a log-fashion automatically for semilogx and loglog plots, thus I consider this a bug. I'm using sage 6.2 right now. Any ideas how to workaround/fix this?

w = var('w')
A0=1e7
w0=100
A(w)=A0*(1/(1+i*w/w0))
plot_semilogx(abs(A(w)),1,1e7)

edit retag close merge delete

## Comments

a) wlist=[10^(_/3) for _ in 3*[1..log(1e7,10)]] would create the typical 1/2/5/10 distribution. I don't see a way to pass this to the plot function, though. b) abslist=[abs(A(_)) for _ in wlist] would calculate the results to be plottod with p=list_plot(zip(abslist, wlist)) in linear scale with log distribution of x-points. However, setting this plot to logscale with p.show(scale=('semilogx',10)) doesn't seem to be possible.

( 2014-09-27 09:46:37 -0500 )edit

A combination of adaptive recursion and huge points seems to be slightly faster. However, I wouldn't call this a solution yet. Unless you know how the plot should look like it's hard to tell if points are sufficient or not. Extending the x-range a few more decades is enough to run into new problems. Only increasing adaptive_recursion does not work because it seems to have a limit of 100 (testing with sage 6.3 now). My starting point for now is plot(abs(A(w)),1,1e10,scale='semilogx',adaptive_recursion=100,plot_points=1000)

( 2014-10-03 07:04:01 -0500 )edit