Hello all, Should generate_plot_points() be modified to log-sample on plots where the x scale is logarithmic? I'd be willing to write the patch up but I'd like to know that it would be desired behavior before I do so.
I've been using sage to graph the frequency responses of a couple of filters. While I was generating the plots, the results sage generated by default were not correct - sage had picked too few sample points. Increasing the number of points by an order of magnitude worked, but it significantly slowed generation of the figures, which was undesirable as I was looking to make them interactive. Restating the function in terms of x <- 2^x and changing the axes appropriately solved the problem. I think plot() should 'just work' the way one would intuitively expect. However, I don't know - there may be (/probably are) use cases where this would be far from expected behavior. Code, to illustrate: def mag2db(x): return 20*log(x, 10) def plot_tf(tf, cutoff, var, domain=(1, 1e6), thresh=1e-2, **kwargs): tf = tf.substitute({var:var*i}) return plot_semilogx(mag2db(abs(tf)), (var, domain[0], domain[1]), base= 2, **kwargs) def plot_tf_log(tf, cutoff, var, domain=(1, 1e6), thresh=1e-2, **kwargs): tf = tf.substitute({var:2^(var)*i}) return plot(mag2db(abs(tf)), (var, log(domain[0], 2), log(domain[1], 2 )), **kwargs) @interact def _(w=slider(0, 20000, step_size=500, default=2000, label='$\\omega_c$'), R=slider(0, 5, default=1, step_size=0.2), C=slider(0, 10, default=1, step_size=0.2)): l = L.substitute(omega_c=w, r=R, c=C) b = B.substitute(omega_c=w, r=R, c=C) h = H.substitute(omega_c=w, r=R, c=C) p = plot_tf(l, w, s, color='blue') p += plot_tf(b, w, s, color='red') p += plot_tf(h, w, s, color='green') p.show(ymin=-30, ymax=5) p2 = plot_tf_log(l, w, s, color='blue') p2 += plot_tf_log(b, w, s, color='red') p2 += plot_tf_log(h, w, s, color='green') p2.show(ymin=-30, ymax=5) print(l) # 4000000/(s^2 + 4000*s + 4000000) print(b) # 2000*s/(s^2 + 4000*s + 4000000) print(h) # s^2/(s^2 + 4000.00000000000*s + 4000000) [image: a.png] <about:invalid#zClosurez>[image: b.png] Thanks, Blair Mason -- You received this message because you are subscribed to the Google Groups "sage-devel" group. To unsubscribe from this group and stop receiving emails from it, send an email to sage-devel+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/sage-devel/7164f726-788d-4718-8ddc-90eba8e858ce%40googlegroups.com.