ASKSAGE: Sage Q&A Forum - Individual question feedhttp://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Fri, 03 Oct 2014 07:04:01 -0500how to get a log distribution on the x-axis of a semilogx plot?http://ask.sagemath.org/question/24310/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)Sat, 27 Sep 2014 08:32:32 -0500http://ask.sagemath.org/question/24310/how-to-get-a-log-distribution-on-the-x-axis-of-a-semilogx-plot/Comment by gg@g for <p>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?</p>
<pre><code>w = var('w')
A0=1e7
w0=100
A(w)=A0*(1/(1+i*w/w0))
plot_semilogx(abs(A(w)),1,1e7)
</code></pre>
http://ask.sagemath.org/question/24310/how-to-get-a-log-distribution-on-the-x-axis-of-a-semilogx-plot/?comment=24383#post-id-24383A 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)Fri, 03 Oct 2014 07:04:01 -0500http://ask.sagemath.org/question/24310/how-to-get-a-log-distribution-on-the-x-axis-of-a-semilogx-plot/?comment=24383#post-id-24383Comment by gg@g for <p>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?</p>
<pre><code>w = var('w')
A0=1e7
w0=100
A(w)=A0*(1/(1+i*w/w0))
plot_semilogx(abs(A(w)),1,1e7)
</code></pre>
http://ask.sagemath.org/question/24310/how-to-get-a-log-distribution-on-the-x-axis-of-a-semilogx-plot/?comment=24312#post-id-24312a) 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.Sat, 27 Sep 2014 09:46:37 -0500http://ask.sagemath.org/question/24310/how-to-get-a-log-distribution-on-the-x-axis-of-a-semilogx-plot/?comment=24312#post-id-24312