Transforming a color scale

In developing plots, I often use color (or “colour” in ggplot2 parlance) to reflect values of a third, non-X/Y, variable. Depending on the distribution of this Z variable, however, the effective color range can be narrow, making it difficult to discriminate between Z values, as in this plot:

As you can see, the bulk of the points are in the middle, yellow/white range, while green/blue and orange/red only appear near the edges. This is as it should be, since Z = X * Y, and there are relatively few extreme values. However, I am, in a sense, “wasting” a lot of the color range available to me. Fortunately, the package scales offers a function called trans_new(), which permits one to apply any function on the distribution, as I do below. (Thanks to “mnel” at