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 stackoverflow.com.)

*Related*

To

**leave a comment** for the author, please follow the link and comment on their blog:

** is.R()**.

R-bloggers.com offers

**daily e-mail updates** about

R news and

tutorials on topics such as:

Data science,

Big Data, R jobs, visualization (

ggplot2,

Boxplots,

maps,

animation), programming (

RStudio,

Sweave,

LaTeX,

SQL,

Eclipse,

git,

hadoop,

Web Scraping) statistics (

regression,

PCA,

time series,

trading) and more...

If you got this far, why not

__subscribe for updates__ from the site? Choose your flavor:

e-mail,

twitter,

RSS, or

facebook...

**Tags:** ggplot2, graphics, RColorBrewer, rstats, scales