psweep.psweep.logspace

Contents

psweep.psweep.logspace#

psweep.psweep.logspace(start, stop, num=50, offset=0, log_func=<ufunc 'log10'>, **kwds)[source]#

Like numpy.logspace but

  • start and stop are not exponents but the actual bounds

  • tuneable log scale strength

Control the strength of the log scale by offset, where we use by default log_func=np.log10 and base=10 and return np.logspace(np.log10(start + offset), np.log10(stop + offset)) - offset. offset=0 is equal to np.logspace(np.log10(start), np.log10(stop)). Higher offset values result in more evenly spaced points.

Parameters:
  • start – same as in np.logspace

  • stop – same as in np.logspace

  • num – same as in np.logspace

  • **kwds – same as in np.logspace

  • offset – Control strength of log scale.

  • log_func (Callable) – Must match base (pass that as part of **kwds). Default is base=10 as in np.logspace and so log_func=np.log10. If you want a different base, also provide a matching log_func, e.g. base=e, log_func=np.log.

Examples

Effect of different offset values:

>>> from matplotlib import pyplot as plt
>>> from psweep import logspace
>>> import numpy as np
>>> for ii, offset in enumerate([1e-16,1e-3, 1,2,3]):
...     x=logspace(0, 2, 20, offset=offset)
...     plt.plot(x, np.ones_like(x)*ii, "o-", label=f"{offset=}")
>>> plt.legend()