# color numbers by y-axos
plot(mtcars$hp, mtcars$mpg, col=num2col(mtcars$mpg), pch=19)
# color only a certain range
plot(mtcars$hp, mtcars$mpg, col=num2col(mtcars$mpg, ref=c(20, 35)), pch=19)
# hide the out of range values
plot(mtcars$hp, mtcars$mpg, col=num2col(mtcars$mpg, ref=c(20,35), NAcol=NA))
# iris example
pairs(iris[,-5], col=num2col(iris$Sepal.Length))
# same butusing a prepared coloring function (for values in range 0-10)
color <- num2col(ref=c(0,10))
pairs(iris[,-5], col=color(iris$Sepal.Length))
Run the code above in your browser using DataLab