Reputation: 11376
I have following type of data and I want to produce bar graph.
Mark <- 1:10
Post <- c(0, 1, 4, 5, 6,
8, 10, 11, 12, 13)
color <- c(1,0.5,1, 1, 0.6, 0.7, 1,1,1) # 9 intervals between ten points
Here ten Mark should be in Post in X axis. Instead of bar height is constant however color coded by color variable. For example interval between 1-2 corresponds to 1 color value while 2-3 corresponds to color value 0.5. Thus for 10 Mark there are 9 color values.
How can produce such a graph ?
EDITS:
It would be perfect if I could add the color scale legend - color intensity vs numeric value
Upvotes: 1
Views: 1190
Reputation: 66844
Not perfect, but should get you started:
greens <- colorRampPalette(c("white","darkgreen"))
barplot(as.matrix(diff(Post)), horiz=T, col=greens(10)[10*color], axes=F, xlab="Mark")
axis(1, labels=Mark, at=Post)
axis(3, labels=Post, at=Post)
Upvotes: 4