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
p1 = plot(expr, (x, -5, 5),
        "distance from (0, 0)", {"cmap": "plasma"},
        ylim=(-10, 10), detect_poles=True, n=3e04,
        eps=1e-04, color_func=cf, title="$%s$" % latex(expr))
