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)
Thanks,
Blair Mason
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.
Le jeudi 16 avril 2020 06:21:42 UTC+2, Blair Mason:
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.Yes please! Thanks for your initiative!The current sampling is definitely annoying for log plots.