Please keep the list in CC. Maybe something like
dat.vline <- data.frame( variable = c("runmean_10yr_Nino_3_Index_17th_century", "runmean_10yr_Nino_3_Index_17th_century", "runmean_10yr_Nino_3_Index_18th_century", "runmean_10yr_Nino_3_Index_17th_century"), xval = c(55, 65, 72, 82)) and geom_vline(aes(xintercept = xval),data=dat.vline) will work. If not take a look from the melted data.frame - the dat.vline should be of similar structure. On Fri, 8 Jan 2016 at 18:41 <maet...@students.unibe.ch> wrote: > I tried the following. Still isnt working, now having 8 lines on ever > plot. I dont get the structure of the functions here.. > > Matthias > > ggplot(data=melted3, aes(x=time_Nino3,y=value,colour=variable))+ > geom_line()+ ylab("SST Anomaly") + xlab("year") + ggtitle("Decadal El > Nino Index ")+ facet_grid(variable ~ .) + > geom_vline(aes(xintercept = > runmean_10yr_Nino_3_Index_18th_century),data=dat.vline) > > a<- c(55,65) > b<- c(72,82) > c<- c(10,80) > d <- c(57,97) > dat.vline <- data.frame( runmean_10yr_Nino_3_Index_17th_century = c(a, b), > runmean_10yr_Nino_3_Index_18th_century=c(c,d)) > ________________________________________ > Von: R-help [r-help-boun...@r-project.org]" im Auftrag von > "Ulrik Stervbo [ulrik.ster...@gmail.com] > Gesendet: Freitag, 8. Januar 2016 18:02 > An: Matthias Worni; r-help@r-project.org > Betreff: Re: [R] (no subject) > > Hi Matthias, > > Your dat.vline should include the 'variable' as you facet on this. > > HTH > > On Fri, 8 Jan 2016 at 17:49 Matthias Worni <wornimatth...@gmail.com> > wrote: > > > Thank you for the help. It worked out fine. However trying to add > > additional aesthetics I came to another point, where I couldnt figure > out a > > way to solve it. Perhaps you run into similar problems since your > familiar > > with the ggplot package. > > > > The code is the following: > > > > runmean_10yr_Nino_3_Index_17th_century <- > > SMA(SST_NINO3_detrended[0:100],n=10) > > runmean_10yr_Nino_3_Index_18th_century <- > > SMA(SST_NINO3_detrended[101:200],n=10) > > runmean_10yr_Nino_3_Index_19th_century <- > > SMA(SST_NINO3_detrended[201:300],n=10) > > runmean_10yr_Nino_3_Index_20th_century <- > > SMA(SST_NINO3_detrended[301:400],n=10) > > > > > > time_Nino3 <- c(1:100) > > runmean_yearly_decadal_Nino_Index <- > > > > > data.frame(runmean_10yr_Nino_3_Index_17th_century,runmean_10yr_Nino_3_Index_18th_century,runmean_10yr_Nino_3_Index_19th_century,runmean_10yr_Nino_3_Index_20th_century,time_Nino3) > > melted3 <- melt(runmean_yearly_decadal_Nino_Index , id.vars="time_Nino3") > > > > ggplot(data=melted3, aes(x=time_Nino3,y=value,colour=variable))+ > > geom_line()+ ylab("SST Anomaly") + xlab("year") + ggtitle("Decadal El > > Nino Index ")+ facet_grid(variable ~ .) + > > geom_vline(aes(xintercept = xp),data=dat.vline) > > > > dat.vline <- data.frame( xp = c(15, 23)) > > > > > > As you may have noticed I created several plots below each other and now > I > > would like to add vertical lines to this plots, therefore adding > > "geom_vline(aes(xintercept = xp),data=dat.vline). This worked so far, > > however I would like to add vertical lines for these four different plots > > at different places. Do you know how I could do this? I added the plot I > > created at this e-mail. You can see two lines on every of those 4 plots > (at > > the same place). What I want is the same thing but the lines at different > > places for every of those 4 plots (independently). Thank you for the > help!! > > If you need to create the plots you can simply change the > > "runmean_10yr_Nino_3_Index_17th_century" to any other vector. > > > > Best Matthias > > ______________________________________________ > > R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see > > https://stat.ethz.ch/mailman/listinfo/r-help > > PLEASE do read the posting guide > > http://www.R-project.org/posting-guide.html > > and provide commented, minimal, self-contained, reproducible code. > > > > [[alternative HTML version deleted]] > > ______________________________________________ > R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide > http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. > [[alternative HTML version deleted]] ______________________________________________ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.