r - geom_rect() main variable not found -


i want plot rectangle "shading" in ggplot. ggplot code works , provides image shown below. looked information here , constructed data frame x , y values.

mydf<-data.frame(tiempo=df5$tiempo,vel=df5$tr2x45.17)[1:14,] structure(list(tiempo = c(618.2, 618.4, 618.6, 618.8, 619, 619.2,  619.4, 619.6, 619.8, 620, 620.2, 620.4, 620.6, 620.8), vel = c(0,  0, -4, -9, 5, 9, 1, 4, 0, 0, -1, -4, 0, 1)), .names = c("tiempo",  "vel"), row.names = c(na, 14l), class = "data.frame")  rects <- data.frame(xstart = seq(618,619.5,.5), xend = seq(618.5,620,.5), col = letters[1:4])  ggplot(data=mydf,        aes(x=tiempo,y=vel))+theme_minimal()+            geom_point(size=4)+     labs(title=c("velocidad ejemplo pasaje figura"))+        geom_smooth(method="loess", span=.3, se=false, colour="red", size=1,alpha=0.5) + geom_rect(data = rects, aes(xmin = xstart, xmax = xend, ymin = -inf, ymax = inf, fill = col), alpha = 0.4)  

if run code until geom_smooth(...) line produces plot. if add geom_rect(...) gives error back: error in eval(expr, envir, enclos) : object 'tiempo' not found

enter image description here

i don't understand mean "tiempo" not being found while everyother thing finds it. also, i'm using dataframe geom_rect() why looking tiempo there?

ok. this:

geom_rect(inherit.aes = false, data = rects, aes(xmin = xstart, xmax = xend, ymin = -inf, ymax = inf, fill = col), alpha = 0.4) 

Comments

Popular posts from this blog

python - TypeError: start must be a integer -

c# - DevExpress RepositoryItemComboBox BackColor property ignored -

django - Creating multiple model instances in DRF3 -