Possible Duplicate:
Shading a kernel density plot between two points
I want to produce a density plot with certain portion highlighted..
myd <- c(2,4,5, 4,3,2,2,3,3,3,2,3,3,4,2,4,3,3,3,2,2.5, 2, 3,3, 2.3, 3, 3, 2, 3)
I want to create density plot and color, the portion greater than 3 to end of the curve .
My unsuccessful codes
plot(density(myd),xlim=c(0,5))
polygon(c(3, myd, max(myd)),c(0,density(myd),0.6),col="tan")
polygon(c(3, myd, max(myd)),c(0,density(myd),0.6),col="tan")
Error in xy.coords(x, y) : 'x' and 'y' lengths differ
polygon(c(3, myd, max(myd)),c(0,myd,0.6),col="tan")
produce a graph, obviously but awful, not closer to what I need !