Suppose I have this data-set:
d <- data.frame("year"=c(2000:2005), "val"=c(rnorm(6,0,1)))
I want to show the val
against year
, but I don't want line, points or bar plots. Instead, I want to use val
values showing with stretched colors covering entire background of plot area. Any suggestion?
From what you're describing you have two options:
Data: d <- data.frame("year"=c(2000:2005), "val"=c(rnorm(6,0,1)))
(1) Ggplot
library(ggplot2)
ggplot(data=d) + geom_tile(aes(x=year,y=1,fill=val))
barplot(table(d$year),col=colorRampPalette(c('cadetblue1', 'cadetblue4'))(length(d$val))[rank(d$val)])
In the base R example, Dark = higher values of d$val
whereas light = lower values of d$val
.