August 2017
Beginner to intermediate
334 pages
8h 22m
English
The logarithmic scale described in the previous section supports positive numbers only. Suppose y = ab, where a is positive; y must be also positive if b equals to any real number (positive, negative, whole numbers, and decimal numbers). When y approaches zero, the limit of the base a logarithm of y is minus infinity. Meanwhile, the base a logarithm of a negative number is undefined. If we try to supply non-positive numbers (≤0) to numpy.log(), we see the following errors:
import numpy as npnp.log(0)# Output: -infnp.log(-1)# Output: nan
Matplotlib provides three ways to address non-positive numbers in a logarithmic scale.
Firstly, Matplotlib can mask non-positive values as invalid. This is equivalent to specifying ...
Read now
Unlock full access