import numpy as np
expr = 1 / cos(10 * x) + 5 * sin(x)
def cf(x, y):
    # map a colormap to the distance from the origin
    d = np.sqrt(x**2 + y**2)
    # visibility of the plot is limited: ylim=(-10, 10). However,
    # some of the y-values computed by the function are much higher
    # (or lower). Filter them out in order to have the entire
    # colormap spectrum visible in the plot.
    offset = 12 # 12 > 10 (safety margin)
    d[(y > offset) | (y < -offset)] = 0
    return d
graphics(
    line(
        expr, (x, -5, 5), "distance from (0, 0)",
        rendering_kw={"cmap": "plasma"},
        adaptive=False, detect_poles=True, n=3e04,
        eps=1e-04, color_func=cf),
    line(5 * sin(x), (x, -5, 5), rendering_kw={"linestyle": "--"}),
    ylim=(-10, 10), title="$%s$" % latex(expr)
)
# Expected:
## Plot object containing:
## [0]: cartesian line: 5*sin(x) + 1/cos(10*x) for x over (-5.0, 5.0)
## [1]: cartesian line: 5*sin(x) for x over (-5.0, 5.0)
