Created
November 25, 2014 21:39
-
-
Save abikoushi/e1869bcd7fb097b12c44 to your computer and use it in GitHub Desktop.
paint the color on a part of the histogram.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
histcol <-function(hst, from, to, col="cornflowerblue"){ | |
bw<-diff(hst$breaks)[1] | |
part<-c(from,to) | |
xv <-seq(part[1],part[2],bw) | |
yv <- hst$counts[hst$breaks[-length(hst$breaks)] %in% xv] | |
for(k in 1:(length(xv)-1)){ | |
polygon(sort(rep(xv[k:(k+1)], 2)), c(0,rep(yv[k], 2),0), | |
col=col) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Argument
hst: histogram object
from: specified by the x coordinate the beginning of add color range
to: specified by the x coordinate the end of add color range
col: color
Example